summary refs log tree commit diff stats
path: root/lib/system/strmantle.nim
diff options
context:
space:
mode:
authorArne Döring <arne.doering@gmx.net>2019-05-29 16:48:00 +0200
committerAndreas Rumpf <rumpf_a@web.de>2019-05-29 16:48:00 +0200
commit88b5dd33626dcd9a9abfd6c9e316bc6c79eb1b21 (patch)
treea1e3b51b420c48627ecee0b9f9882e97543244e7 /lib/system/strmantle.nim
parent897e7c90ac148d7a3b63ac9b7f99e464147cfb03 (diff)
downloadNim-88b5dd33626dcd9a9abfd6c9e316bc6c79eb1b21.tar.gz
right shift is now by default sign preserving (#11322)
* right shift is now by default sign preserving
* fix hashString and semfold
* enable arithmetic shift right globally for CI
* fix typo
* remove xxx
* use oldShiftRight as flag
* apply feedback
* add changelog entry
Diffstat (limited to 'lib/system/strmantle.nim')
-rw-r--r--lib/system/strmantle.nim12
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/system/strmantle.nim b/lib/system/strmantle.nim
index 8ff2e0ee0..457e0eab5 100644
--- a/lib/system/strmantle.nim
+++ b/lib/system/strmantle.nim
@@ -30,15 +30,15 @@ proc eqStrings(a, b: string): bool {.inline, compilerProc.} =
 proc hashString(s: string): int {.compilerproc.} =
   # the compiler needs exactly the same hash function!
   # this used to be used for efficient generation of string case statements
-  var h = 0
+  var h : uint = 0
   for i in 0..len(s)-1:
-    h = h +% ord(s[i])
-    h = h +% h shl 10
+    h = h + uint(s[i])
+    h = h + h shl 10
     h = h xor (h shr 6)
-  h = h +% h shl 3
+  h = h + h shl 3
   h = h xor (h shr 11)
-  h = h +% h shl 15
-  result = h
+  h = h + h shl 15
+  result = cast[int](h)
 
 proc addInt*(result: var string; x: int64) =
   ## Converts integer to its string representation and appends it to `result`.