[speed up name choosing a little
John Meacham <john@repetae.net>**20100806111703
 Ignore-this: ac159eeb0d34a7d26ad74253d00386ae
] hunk ./src/E/SSimplify.hs 1029
+    idsSeed :: {-# UNPACK #-} !Int,
hunk ./src/E/SSimplify.hs 1034
-smState = SmState { idsUsed = mempty, idsBound = mempty }
+smState = SmState { idsSeed = 1, idsUsed = mempty, idsBound = mempty }
hunk ./src/E/SSimplify.hs 1077
-        (used,bound) <- getIds
-        newNameFrom $ candidateIds (size used + 10000*size bound)
+        seed <- gets idsSeed
+        modify (\e -> e { idsSeed = seed + 1 })
+--        (used,bound) <- getIds
+        newNameFrom $ candidateIds seed -- (size used + 10000*size bound)
hunk ./src/Name/Id.hs 41
+import Data.Word
hunk ./src/Name/Id.hs 219
-        fromIdNameT $ newNameFrom (candidateIds (size used `xor` size bound))
+        fromIdNameT $ newNameFrom (candidateIds (size used `xor` 128 * size bound))
hunk ./src/Name/Id.hs 289
-candidateIds seed = map mask $ randoms (mkStdGen seed) where
-    mask x = Id $ x .&. 0x0FFFFFFE
+candidateIds !seed = f (2 + (mask $ hashInt seed)) where
+    mask x = x .&. 0x0FFFFFFE
+    f !x = Id x:f (x + 2)
hunk ./src/Name/Id.hs 294
+hashInt :: Int -> Int
+hashInt x = fromIntegral $ f (fromIntegral x) where
+    f :: Word -> Word
+    f a = a''''' where
+        !a' = (a `xor` 61) `xor` (a `shiftR` 16)
+        !a'' = a' + (a' `shiftL` 3)
+        !a''' = a'' `xor` (a'' `shiftR` 4)
+        !a'''' = a''' * 0x27d4eb2d
+        !a''''' = a'''' `xor` (a'''' `shiftR` 15)