diff options
author | Charles Blake <cblake@csail.mit.edu> | 2015-02-16 07:48:31 -0500 |
---|---|---|
committer | Charles Blake <cblake@csail.mit.edu> | 2015-02-16 07:48:31 -0500 |
commit | 629decd1701742daf115c4a550a219af17b488c1 (patch) | |
tree | c3f0ffa652de11a2162351ff509101e6aa0b1a65 /lib/pure | |
parent | db257669c36ae39d79ad25c69ab00151d958ae5a (diff) | |
download | Nim-629decd1701742daf115c4a550a219af17b488c1.tar.gz |
Add comments explaining odd looking i<0..data[i].
Diffstat (limited to 'lib/pure')
-rw-r--r-- | lib/pure/collections/tables.nim | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/pure/collections/tables.nim b/lib/pure/collections/tables.nim index ca543780f..2edd65968 100644 --- a/lib/pure/collections/tables.nim +++ b/lib/pure/collections/tables.nim @@ -235,7 +235,7 @@ template maybeRehashPutImpl() {.dirty.} = if mustRehash(len(t.data), t.counter): enlarge(t) index = rawGetKnownHC(t, key, hc) - index = -1 - index + index = -1 - index # important to transform for mgetOrPutImpl rawInsert(t, t.data, key, val, hc, index) inc(t.counter) @@ -248,8 +248,8 @@ template putImpl() {.dirty.} = template mgetOrPutImpl() {.dirty.} = var hc: THash var index = rawGet(t, key, hc) - if index < 0: maybeRehashPutImpl() # not present: insert - result = t.data[index].val # either way return modifiable val + if index < 0: maybeRehashPutImpl() # not present: insert (flipping index) + result = t.data[index].val # either way return modifiable val template hasKeyOrPutImpl() {.dirty.} = var hc: THash |