The Inbox: Collections-cbc.651.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Inbox: Collections-cbc.651.mcz

commits-2
A new version of Collections was added to project The Inbox:
http://source.squeak.org/inbox/Collections-cbc.651.mcz

==================== Summary ====================

Name: Collections-cbc.651
Author: cbc
Time: 31 August 2015, 3:53:15.138 pm
UUID: 1d7408f6-a290-0d4b-8b83-6a6a2e4f325e
Ancestors: Collections-cbc.650

Faster #unsignedLong64At:bigEndian:

=============== Diff against Collections-cbc.650 ===============

Item was changed:
  ----- Method: ByteArray>>unsignedLong64At:bigEndian: (in category 'platform independent access') -----
  unsignedLong64At: index bigEndian: aBool
+ "Avoid as much largeInteger as we can"
+ | b0 b2 b3 b5 b6 w n2 n3 |
+
+ aBool ifFalse: [
+ w := self at: index.
+ b6 := self at: index+1.
+ b5 := self at: index+2.
+ n2 := self at: index+3.
+ b3 := self at: index+4.
+ b2 := self at: index+5.
+ n3 := self at: index+6.
+ b0 := self at: index+7.
+ ] ifTrue: [
+ b0 := self at: index.
+ n3 := self at: index+1.
+ b2 := self at: index+2.
+ b3 := self at: index+3.
+ n2 := self at: index+4.
+ b5 := self at: index+5.
+ b6 := self at: index+6.
+ w := self at: index+7.
+ ].
+
+ "Minimize LargeInteger arithmetic"
+ b6 = 0 ifFalse:[w := (b6 bitShift: 8) + w].
+ b5 = 0 ifFalse:[w := (b5 bitShift: 16) + w].
+
+ b3 = 0 ifFalse:[n2 := (b3 bitShift: 8) + n2].
+ b2 = 0 ifFalse:[n2 := (b2 bitShift: 16) + n2].
+ n2 == 0 ifFalse: [w := (n2 bitShift: 24) + w].
+
+ b0 = 0 ifFalse:[n3 := (b0 bitShift: 8) + n3].
+ n3 == 0 ifFalse: [w := (n3 bitShift: 48) + w].
+
+ ^w!
- | n1 n2 |
- aBool
- ifTrue: [
- n2 := self unsignedLongAt: index  bigEndian: true.
- n1 := self unsignedLongAt: index+4  bigEndian: true.
- ]
- ifFalse: [
- n1 := self unsignedLongAt: index bigEndian: false.
- n2 := self unsignedLongAt: index+4 bigEndian: false.
- ].
- ^(n2 bitShift: 32) + n1!