The Trunk: Nebraska-ul.32.mcz

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

The Trunk: Nebraska-ul.32.mcz

commits-2
Levente Uzonyi uploaded a new version of Nebraska to project The Trunk:
http://source.squeak.org/trunk/Nebraska-ul.32.mcz

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

Name: Nebraska-ul.32
Author: ul
Time: 28 February 2011, 7:42:18.721 am
UUID: ee0e143b-7c07-0c49-9505-edac998570ca
Ancestors: Nebraska-nice.31

Moved String's #getInteger32: and #putInteger32:at: to this package. The methods only make sense for ByteStrings.
Both methods are rewritten to
- avoid creation of LargeIntegers
- use fast integer and string manipulation methods
- use the stack optimally if possible
The new methods are 2-15x faster than the previous implementations. Combining this with the speedup of Cog, the use of IntegerPokerPlugin is probably unnecessary (it's not present in current VMs).

=============== Diff against Nebraska-nice.31 ===============

Item was added:
+ ----- Method: ByteString>>getInteger32: (in category '*Nebraska') -----
+ getInteger32: location
+ "Read a SmallInteger stored in the receiver using big-endian one's complement representation. Avoid creation of LargeIntegers."
+
+ | firstByte |
+ (firstByte := self byteAt: location) < 64 ifTrue: [
+ ^(((((
+ firstByte bitShift: 8) bitOr:
+ (self byteAt: location + 1)) bitShift: 8) bitOr:
+ (self byteAt: location + 2)) bitShift: 8) bitOr:
+ (self byteAt: location + 3) ].
+ ^(64 - firstByte bitShift: 24) - (((((
+ (self byteAt: location + 1)) bitShift: 8) bitOr:
+ (self byteAt: location + 2)) bitShift: 8) bitOr:
+ (self byteAt: location + 3))
+ !

Item was added:
+ ----- Method: ByteString>>putInteger32:at: (in category '*Nebraska') -----
+ putInteger32: anInteger at: location
+ "Store a SmallInteger in the receiver using big-endian one's complement representation. Avoid creation of LargeIntegers."
+
+ | integer firstByte |
+ (integer := anInteger) >= 0
+ ifTrue: [ firstByte := (anInteger bitShift: -24) bitAnd: 255 ]
+ ifFalse: [
+ integer := 0 - integer.
+ firstByte := (integer bitShift: -24) + 64 bitAnd: 255 ].
+ self
+ byteAt: location put: firstByte;
+ byteAt: location + 1 put: ((integer bitShift: -16) bitAnd: 255);
+ byteAt: location + 2 put: ((integer bitShift: -8) bitAnd: 255);
+ byteAt: location + 3 put: (integer bitAnd: 255)
+ !