Nicolas Cellier uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-nice.249.mcz==================== Summary ====================
Name: Collections-nice.249
Author: nice
Time: 10 December 2009, 6:36:07 am
UUID: 4e2e3a9e-98ca-1f48-9ead-1b32c2a196dc
Ancestors: Collections-nice.248
Oops, sorry for double posting, I forgot to update the comment.
Note that it would be interesting to see how non inlined version performs in COG:
| byte byteOffset |
1 to: aMap size do: [:i |
(byte := aMap at: i) = 0 ifFalse: [
byteOffset := (i bitShift: 3) - 9.
[aBlock value: (byteOffset + byte lowBit).
(byte := byte bitAnd: byte - 1) = 0] whileFalse]]
=============== Diff against Collections-nice.248 ===============
Item was changed:
----- Method: WideCharacterSet>>bitmap:do: (in category 'private') -----
bitmap: aMap do: aBlock
"Execute a block with each value (0 based) corresponding to set bits.
+ Implementation notes: this version works best for sparse maps.
+ It has (byte lowBit) inlined for speed."
- Implementation: this version works best for sparse maps.
- The powers of two and highBit tables are inlined for speed"
| byte byteOffset lowBits |
+ lowBits := #[1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 6 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 7 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 6 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 8 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 6 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 7 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 6 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1]. "The lowBits table gives a 1-based bitOffset"
- lowBits := #[1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 6 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 7 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 6 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 8 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 6 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 7 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 6 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1]. "The lowBits table is a 1-based bitOffset"
1 to: aMap size do: [:i |
(byte := aMap at: i) = 0 ifFalse: [
byteOffset := (i bitShift: 3) - 9. "This byteOffset is -1 based"
["Evaluate the block with 0-based (byteOffset + bitOffset)"
aBlock value: (byteOffset + (lowBits at: byte)).
"Eliminate the low bit and loop if some bit remain"
(byte := byte bitAnd: byte - 1) = 0] whileFalse]]!