[m-rev.] diff: speed up string hashing

Zoltan Somogyi zs at csse.unimelb.edu.au
Wed Sep 3 14:39:05 AEST 2008


library/string.m:
	Speed up hashing by eliminating a check that cannot fail.

Zoltan.

cvs diff: Diffing .
Index: string.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/string.m,v
retrieving revision 1.275
diff -u -b -r1.275 string.m
--- string.m	29 Aug 2008 06:13:09 -0000	1.275
+++ string.m	29 Aug 2008 09:45:19 -0000
@@ -1703,7 +1703,7 @@
 :- pred string.combine_hash(int::in, int::in, int::out) is det.
 
 string.combine_hash(X, H0, H) :-
-    H1 = H0 `xor` (H0 << 5),
+    H1 = H0 `xor` (H0 `unchecked_left_shift` 5),
     H = H1 `xor` X.
 
 %-----------------------------------------------------------------------------%
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list