diff options
Diffstat (limited to 'lib/pure')
-rw-r--r-- | lib/pure/hashes.nim | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/pure/hashes.nim b/lib/pure/hashes.nim index 2ce8ac796..c6af8f918 100644 --- a/lib/pure/hashes.nim +++ b/lib/pure/hashes.nim @@ -38,7 +38,7 @@ ## result = !$h import - strutils + strutils, etcpriv type THash* = int ## a hash value; hash tables using these values should @@ -124,13 +124,21 @@ proc hash*(x: string): THash = proc hashIgnoreStyle*(x: string): THash = ## efficient hashing of strings; style is ignored var h: THash = 0 - for i in 0..x.len-1: + var i = 0 + let xLen = x.len + while i < xLen: var c = x[i] if c == '_': + inc(i) continue # skip _ + if isMagicIdentSeparatorRune(cstring(x), i): + inc(i, magicIdentSeparatorRuneByteWidth) + continue # skip 'ยท' (unicode middle dot) if c in {'A'..'Z'}: c = chr(ord(c) + (ord('a') - ord('A'))) # toLower() h = h !& ord(c) + inc(i) + result = !$h proc hashIgnoreCase*(x: string): THash = |