[squeak-dev] The Trunk: Collections-ul.646.mcz
commits at source.squeak.org
commits at source.squeak.org
Sat Aug 22 12:13:04 UTC 2015
Levente Uzonyi uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-ul.646.mcz
==================== Summary ====================
Name: Collections-ul.646
Author: ul
Time: 22 August 2015, 1:27:33.8 pm
UUID: db0d3568-8710-49c8-826e-3100979e6b48
Ancestors: Collections-ul.645
- removed migration code from WideCharacterSet
=============== Diff against Collections-ul.645 ===============
Item was changed:
----- Method: WideCharacterSet>>add: (in category 'collection ops') -----
add: aCharacter
| value highBits lowBits |
- self migrate.
(value := aCharacter asInteger) < 256 ifTrue: [
byteArrayMap at: value + 1 put: 1 ].
highBits := value bitShift: highBitsShift.
lowBits := value bitAnd: lowBitsMask.
(map at: highBits ifAbsentPut: [ Bitset new: bitsetCapacity ])
setBitAt: lowBits.
^aCharacter!
Item was removed:
- ----- 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."
-
- | byte byteOffset lowBits |
- lowBits := Integer lowBitPerByteTable. "The lowBits table gives 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]]!
Item was changed:
----- Method: WideCharacterSet>>do: (in category 'collection ops') -----
do: aBlock
- self migrate.
map keysAndValuesDo: [ :index :bitset |
| highBits |
highBits := index * bitsetCapacity.
bitset do: [ :lowBits |
aBlock value: (Character value: highBits + lowBits) ] ]!
Item was changed:
----- Method: WideCharacterSet>>includes: (in category 'collection ops') -----
includes: aCharacter
| value |
(value := aCharacter asInteger) < 256 ifTrue: [
^(byteArrayMap at: value + 1) ~= 0 ].
- self migrate.
^((map at: (value bitShift: highBitsShift) ifAbsent: nil) ifNil: [ ^false ])
includes: (value bitAnd: lowBitsMask)!
Item was removed:
- ----- Method: WideCharacterSet>>migrate (in category 'private') -----
- migrate
-
- | newMap |
- bitsetCapacity ifNotNil: [ ^self "already migrated" ].
- self initializeWithLowBits: 8.
- newMap := PluggableDictionary integerDictionary.
- map keysAndValuesDo: [ :index :lowmap |
- | high16Bits |
- high16Bits := index bitShift: 16.
- self
- bitmap: lowmap
- do: [ :low16Bits |
- | value highBits lowBits |
- value := high16Bits + low16Bits.
- highBits := value bitShift: highBitsShift.
- lowBits := value bitAnd: lowBitsMask.
- (newMap at: highBits ifAbsentPut: [ Bitset new: bitsetCapacity ])
- setBitAt: lowBits ] ].
- map := newMap!
Item was changed:
----- Method: WideCharacterSet>>remove:ifAbsent: (in category 'collection ops') -----
remove: aCharacter ifAbsent: aBlock
| value highBits lowBits bitset |
(value := aCharacter asInteger) < 256 ifTrue: [
(byteArrayMap at: value + 1) = 0 ifTrue: [ ^aBlock value ].
byteArrayMap at: value + 1 put: 0 ].
- self migrate.
highBits := value bitShift: highBitsShift.
lowBits := value bitAnd: lowBitsMask.
bitset := (map at: highBits ifAbsent: nil) ifNil: [ ^aBlock value ].
((bitset clearBitAt: lowBits) and: [ bitset size = 0 ]) ifTrue: [
map removeKey: highBits ].
^aCharacter!
More information about the Squeak-dev
mailing list
|