diff options
author | Lolo Iccl <oxisccl@gmail.com> | 2018-05-08 22:09:37 +0900 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2018-05-09 17:41:41 +0200 |
commit | af591544c59e9b05e539f4583f1143776bb8a9e4 (patch) | |
tree | 87dd5fbad4a3ad3e2dcb12dfcef22f0f38c456ec /lib/pure | |
parent | 5c7b66e07a3811b3fa0b8e7bbfe4cf25a6361d3a (diff) | |
download | Nim-af591544c59e9b05e539f4583f1143776bb8a9e4.tar.gz |
Modify hash for HashSet to use `xor` to mix hash of items.
Diffstat (limited to 'lib/pure')
-rw-r--r-- | lib/pure/collections/sets.nim | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/lib/pure/collections/sets.nim b/lib/pure/collections/sets.nim index 94bdbb860..59c90bc2b 100644 --- a/lib/pure/collections/sets.nim +++ b/lib/pure/collections/sets.nim @@ -18,7 +18,7 @@ ## that ``=`` performs a copy of the set. import - hashes, math, algorithm + hashes, math {.pragma: myShallow.} when not defined(nimhygiene): @@ -123,11 +123,8 @@ iterator items*[A](s: HashSet[A]): A = proc hash*[A](s: HashSet[A]): Hash = ## hashing of HashSet assert s.isValid, "The set needs to be initialized." - var hcs: seq[Hash] for h in 0..high(s.data): - hcs.add(s.data[h].hcode) - for hc in sorted(hcs, cmp[int]): - result = result !& hc + result = result xor s.data[h].hcode result = !$result const |