Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 259700

Summary: Excessive garbage collection on Layer.containsPoint
Product: [Tools] GEF Reporter: John Swanke <jswanke>
Component: GEF-Legacy Draw2dAssignee: Anthony Hunter <ahunter.eclipse>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: ahunter.eclipse, danberg, mdelder
Version: 3.4   
Target Milestone: 3.5.0 (Galileo) M5   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description John Swanke CLA 2008-12-26 10:00:06 EST
YourKit pinpoints this method in Layer as having excessive garbage collection. 

This:
	Point pt = new Point(x, y);

should probably be replaced with (as it is in other similar GEF methods)

	Point pt = Point.SINGLETON;
	pt.setLocation(x, y);

The method is:
public boolean containsPoint(int x, int y) {
	if (isOpaque())
		return super.containsPoint(x, y);
	Point pt = new Point(x, y);
	translateFromParent(pt);
	for (int i = 0; i < getChildren().size(); i++) {
		IFigure child = (IFigure)getChildren().get(i);
		if (child.containsPoint(pt.x, pt.y))
			return true;
	}
	return false;
}
Comment 1 Anthony Hunter CLA 2009-01-09 12:31:50 EST
Committed to HEAD