Dec. 23, 2009
8:43 p.m.
why + 1 makes a so big difference?
Because #addAll: has a simple check that doesn't care about the performance of the different methods of addition:
addAll: aCollection aCollection size > (self size // 3) ifTrue: [aCollection do: [:each | self addLast: each]. self reSort] ifFalse: [aCollection do: [:each | self add: each]]. ^ aCollection
A better check could solve this, but who wants to come up with a formula that's easy to calculate (aka fast) and gives accurate results?
Thanks. I like these kind of conversation because they deeply illustrate what I always like in Smalltalk: learning by reading the system. Stef