The Trunk: Collections-eem.745.mcz

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

The Trunk: Collections-eem.745.mcz

commits-2
Eliot Miranda uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-eem.745.mcz

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

Name: Collections-eem.745
Author: eem
Time: 18 April 2017, 11:39:44.905833 am
UUID: c26d3130-3164-4fdb-b302-858a554d8d8d
Ancestors: Collections-eem.744

Clarify the two primitiveStringHash uses.  The one in ByteArray class is translated to a primitive in MiscPrimitivePlugin.  The one in ByteString class is not; it uses the translated primitive derived from ByteArray class>>hashBytes:startingWith:.

(N.B. Requires a soon-to-be-committed change to VMMaker to accet the int decl for speciesHash.")

=============== Diff against Collections-eem.744 ===============

Item was changed:
  ----- Method: ByteArray class>>hashBytes:startingWith: (in category 'byte based hash') -----
  hashBytes: aByteArray startingWith: speciesHash
+ "Answer the hash of a byte-indexed collection, using speciesHash as the initial value.
+ See SmallInteger>>hashMultiply.
- "Answer the hash of a byte-indexed collection,
- using speciesHash as the initial value.
- See SmallInteger>>hashMultiply.
 
+ The primitive should be renamed at a suitable point in the future"
- The primitive should be renamed at a
- suitable point in the future"
-
- | byteArraySize hash low |
  <primitive: 'primitiveStringHash' module: 'MiscPrimitivePlugin'>
+ | byteArraySize hash |
+ <var: 'aByteArray' type: #'unsigned char *'>
+ <var: 'speciesHash' type: #int>
- <var: #aHash declareC: 'int speciesHash'>
- <var: #aByteArray declareC: 'unsigned char *aByteArray'>
 
  byteArraySize := aByteArray size.
  hash := speciesHash bitAnd: 16rFFFFFFF.
+ 1 to: byteArraySize do:
+ [:pos |
- 1 to: byteArraySize do: [:pos |
  hash := hash + (aByteArray basicAt: pos).
+ "Inlined hashMultiply, written this way for translation to C."
+ hash := hash * 1664525 bitAnd: 16r0FFFFFFF].
+ ^hash!
- "Begin hashMultiply"
- low := hash bitAnd: 16383.
- hash := (16r260D * low + ((16r260D * (hash bitShift: -14) + (16r0065 * low) bitAnd: 16383) * 16384)) bitAnd: 16r0FFFFFFF.
- ].
- ^ hash!

Item was changed:
  ----- Method: ByteString class>>stringHash:initialHash: (in category 'primitives') -----
  stringHash: aString initialHash: speciesHash
+ "Answer the hash of a byte-indexed string, using speciesHash as the initial value.
+ See SmallInteger>>hashMultiply."
-
- | stringSize hash low |
  <primitive: 'primitiveStringHash' module: 'MiscPrimitivePlugin'>
+ | hash |
-
- <var: #aHash declareC: 'int speciesHash'>
- <var: #aString declareC: 'unsigned char *aString'>
-
- stringSize := aString size.
  hash := speciesHash bitAnd: 16rFFFFFFF.
+ 1 to: aString size do:
+ [:pos |
+ hash := (hash + (aString basicAt: pos)) hashMultiply].
+ ^hash!
- 1 to: stringSize do: [:pos |
- hash := hash + (aString basicAt: pos).
- "Begin hashMultiply"
- low := hash bitAnd: 16383.
- hash := (16r260D * low + ((16r260D * (hash bitShift: -14) + (16r0065 * low) bitAnd: 16383) * 16384)) bitAnd: 16r0FFFFFFF.
- ].
- ^ hash!


Loading...