[MLton-commit] r6972
Vesa Karvonen
vesak at mlton.org
Sun Nov 2 05:42:37 PST 2008
Streamlined the hash functions. In conjunction with earlier change to
avoid allocating a string in IntInf.hash, this seems to slightly increase
collisions on a self compile, but also reduces total allocation and total
compile time.
----------------------------------------------------------------------
U mlton/trunk/mlton/atoms/const.fun
U mlton/trunk/mlton/atoms/word-x-vector.fun
U mlton/trunk/mlton/atoms/word-x-vector.sig
----------------------------------------------------------------------
Modified: mlton/trunk/mlton/atoms/const.fun
===================================================================
--- mlton/trunk/mlton/atoms/const.fun 2008-11-02 13:40:05 UTC (rev 6971)
+++ mlton/trunk/mlton/atoms/const.fun 2008-11-02 13:42:37 UTC (rev 6972)
@@ -69,11 +69,11 @@
fun hash (c: t): word =
case c of
- IntInf i => String.hash (IntInf.toString i)
+ IntInf i => IntInf.hash i
| Null => 0wx0
| Real r => RealX.hash r
- | Word w => Word.fromIntInf (WordX.toIntInf w)
- | WordVector v => String.hash (WordXVector.toString v)
+ | Word w => WordX.hash w
+ | WordVector v => WordXVector.hash v
fun equals (c, c') =
case (c, c') of
Modified: mlton/trunk/mlton/atoms/word-x-vector.fun
===================================================================
--- mlton/trunk/mlton/atoms/word-x-vector.fun 2008-11-02 13:40:05 UTC (rev 6971)
+++ mlton/trunk/mlton/atoms/word-x-vector.fun 2008-11-02 13:42:37 UTC (rev 6972)
@@ -47,6 +47,8 @@
end)))
end
+val hash = String.hash o toString
+
val layout = Layout.str o toString
fun equals (v, v') =
Modified: mlton/trunk/mlton/atoms/word-x-vector.sig
===================================================================
--- mlton/trunk/mlton/atoms/word-x-vector.sig 2008-11-02 13:40:05 UTC (rev 6971)
+++ mlton/trunk/mlton/atoms/word-x-vector.sig 2008-11-02 13:42:37 UTC (rev 6972)
@@ -22,6 +22,7 @@
val equals: t * t -> bool
val forall: t * (WordX.t -> bool) -> bool
val fromString: string -> t
+ val hash : t -> word
val layout: t -> Layout.t
val length: t -> int
val sub: t * int -> WordX.t
More information about the MLton-commit
mailing list