[squeak-dev] The Trunk: Collections-nice.570.mcz
commits at source.squeak.org
commits at source.squeak.org
Sat May 24 22:38:23 UTC 2014
Nicolas Cellier uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-nice.570.mcz
==================== Summary ====================
Name: Collections-nice.570
Author: nice
Time: 25 May 2014, 12:37:21.454 am
UUID: 1069cfcc-6bd7-4d7d-87fb-0a0a546f8a0c
Ancestors: Collections-nice.569
Let's optimize a bit LinkedList>>at:ifAbsent: by scanning the list only once, unlike super.
=============== Diff against Collections-nice.569 ===============
Item was added:
+ ----- Method: LinkedList>>at:ifAbsent: (in category 'accessing') -----
+ at: index ifAbsent: exceptionBlock
+ "Optimized to scan the list once, super would twice."
+ | i |
+ index < 1 ifTrue: [^exceptionBlock value].
+ i := 0.
+ self do: [:link |
+ (i := i + 1) = index ifTrue: [^ link]].
+ ^exceptionBlock value!
More information about the Squeak-dev
mailing list
|