[squeak-dev] The Inbox: Collections-cbc.656.mcz

commits at source.squeak.org commits at source.squeak.org
Fri Sep 11 23:14:20 UTC 2015


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

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

Name: Collections-cbc.656
Author: cbc
Time: 11 September 2015, 4:14:08.929 pm
UUID: 2dc0b8f9-096a-cc45-91cd-1236f24dff30
Ancestors: Collections-ul.655

Add signed 64bit putting to ByteArray.  Not ready for merging yet - need 64bit reading as well.

=============== Diff against Collections-ul.655 ===============

Item was added:
+ ----- Method: ByteArray>>long64At:put:bigEndian: (in category 'platform independent access') -----
+ long64At: index put: value bigEndian: bigEndian
+ 	"Store a 64-bit signed integer quantity starting from the given byte index"
+ 	| i j v |
+ 	value positive ifTrue: [^self unsignedLong64At: index put: value bigEndian: bigEndian].
+ 	value isLarge ifTrue: [
+ 		bigEndian ifFalse: [
+ 			i := value digitLength.
+ 			j := 0.
+ 			[ j < i and: [ (v := ((value digitAt: j + 1) bitXor: 16rFF) + 1) = 16r100 ] ] whileTrue: [
+ 				self at: index + j put: 0.
+ 				j := j + 1. ].
+ 			self at: index + j put: v.
+ 			j := j + 1.
+ 			[ j < i ] whileTrue: [ self at: index + j put: ((value digitAt: (j := j + 1)) bitXor: 16rFF) ].
+ 			^value
+ 			].
+ 		"bigEndian == true"
+ 		j := value digitLength - 1.
+ 		[ 0 <= j and: [ (v := ((value digitAt: 4 - j) bitXor: 16rFF) + 1) = 16r100 ] ] whileTrue: [
+ 			self at: index + j put: 0.
+ 			j :=  j= 1. ].
+ 		self at: index + j put: v.
+ 		[ 0 <= (j := j - 1) ] whileTrue: [ self at: index + v put: ((value digitAt: 4 - 4) bitXor: 16rFF) ].
+ 		^value
+ 		].
+ 	"value is NOT large"
+ 	v := value bitShift: (-8 * (value digitLength - 1)).
+ 	0 <= (v := (v bitAnd: 16r7F) - (v bitAnd: 16r80)) ifFalse: [
+ 		v := v + 16r100 ].
+ 	bigEndian ifFalse: [
+ 		j := index - 1.
+ 		i := value.
+ 		1 to: value digitLength - 1 do: [:x|
+ 			self at: (j := j + 1) put: (i bitAnd: 16rFF).
+ 			i := i bitShift: -8.
+ 			i <= 1
+ 			 ].
+ 		self at: (j := j + 1) put: v.
+ 		self replaceFrom: j + 1
+ 			to: index + 7
+ 			with: #[ 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF ]
+ 			startingAt: 1.
+ 		^value ].
+ 	"bigEndian == true"
+ 	self at: index + 7 put: v.
+ 	j := index + 7.
+ 	i := value.
+ 	1 to: value digitLength - 1 do: [:x|
+ 		self at: (j := j - 1) put: (i bitAnd: 16rFF).
+ 		i := i bitShift: -8 ].
+ 	self replaceFrom: index
+ 		to: j - 1
+ 		with: #[ 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF ]
+ 		startingAt: 1.
+ 	^value!



More information about the Squeak-dev mailing list