[MLton-commit] r5934
Vesa Karvonen
vesak at mlton.org
Thu Aug 23 02:46:46 PDT 2007
Combined generic value hash with the generic type hash. This should
reduce collisions when using a universal type with a hash function like in
the pickling generic. Previously, hashing an int 0 and a word 0w0
produced the same hash value. Now they produce different hash values.
----------------------------------------------------------------------
U mltonlib/trunk/com/ssh/generic/unstable/detail/value/hash.sml
U mltonlib/trunk/com/ssh/generic/unstable/public/value/hash.sig
----------------------------------------------------------------------
Modified: mltonlib/trunk/com/ssh/generic/unstable/detail/value/hash.sml
===================================================================
--- mltonlib/trunk/com/ssh/generic/unstable/detail/value/hash.sml 2007-08-23 09:29:55 UTC (rev 5933)
+++ mltonlib/trunk/com/ssh/generic/unstable/detail/value/hash.sml 2007-08-23 09:46:45 UTC (rev 5934)
@@ -28,7 +28,7 @@
fun hashParam t p =
if #totWidth p < 0 orelse #maxDepth p < 0
then raise Domain
- else fn v => getT t v p
+ else fn v => Word.xorb (Word32.toWord (Arg.typeHash t), getT t v p)
fun hash t = hashParam t {totWidth = 200, maxDepth = 10}
Modified: mltonlib/trunk/com/ssh/generic/unstable/public/value/hash.sig
===================================================================
--- mltonlib/trunk/com/ssh/generic/unstable/public/value/hash.sig 2007-08-23 09:29:55 UTC (rev 5933)
+++ mltonlib/trunk/com/ssh/generic/unstable/public/value/hash.sig 2007-08-23 09:46:45 UTC (rev 5934)
@@ -44,4 +44,7 @@
sharing Rep = Hash
end
-signature WITH_HASH_DOM = TYPE_INFO_CASES
+signature WITH_HASH_DOM = sig
+ include OPEN_CASES TYPE_HASH TYPE_INFO
+ sharing Rep = TypeHash = TypeInfo
+end
More information about the MLton-commit
mailing list