[ENH] Non-allocating Rectangle class>>merging:

Brian T Rice water at tunes.org
Sat Feb 15 00:36:21 UTC 2003


This enhancement avoids allocating new corner points on every iteration,
using the coordinate values themselves and only allocating corners for the
result Rectangle. This was inspired by Eddie Cottingim's measurements of
garbage collecting for certain applications with a lot of elements.

-- 
Brian T. Rice
LOGOS Research and Development
mailto:water at tunes.org
http://tunes.org/~water/
-------------- next part --------------
'From Squeak3.4beta of ''1 December 2002'' [latest update: #5156] on 14 February 2003 at 4:35:47 pm'!
"Change Set:		Rectangle-merging
Date:			14 February 2003
Author:			Brian T Rice <water at tunes.org>

I modified Rectangle class>>merging: to only allocate a new point once all the coordinates have been collected, to correct some GC issues reported by Eddie Cottingim."!


!Rectangle class methodsFor: 'instance creation' stamp: 'btr 2/14/2003 16:29'!
merging: listOfRects 
	"A number of callers of merge: should use this method."
	| minX minY maxX maxY |
	listOfRects
		do: [:r | minX
				ifNil: [minX _ r topLeft x. minY _ r topLeft y.
					maxX _ r bottomRight x. maxY _ r bottomRight y]
				ifNotNil: [minX _ minX min: r topLeft x. minY _ minY min: r topLeft y.
					maxX _ maxX max: r bottomRight x. maxY _ maxY max: r bottomRight y]].
	^ minX at minY corner: maxX at maxY! !



More information about the Squeak-dev mailing list