Add comments explaining odd looking i<0..data[i].
This commit is contained in:
parent
db257669c3
commit
629decd170
1 changed files with 3 additions and 3 deletions
|
|
@ -235,7 +235,7 @@ template maybeRehashPutImpl() {.dirty.} =
|
||||||
if mustRehash(len(t.data), t.counter):
|
if mustRehash(len(t.data), t.counter):
|
||||||
enlarge(t)
|
enlarge(t)
|
||||||
index = rawGetKnownHC(t, key, hc)
|
index = rawGetKnownHC(t, key, hc)
|
||||||
index = -1 - index
|
index = -1 - index # important to transform for mgetOrPutImpl
|
||||||
rawInsert(t, t.data, key, val, hc, index)
|
rawInsert(t, t.data, key, val, hc, index)
|
||||||
inc(t.counter)
|
inc(t.counter)
|
||||||
|
|
||||||
|
|
@ -248,7 +248,7 @@ template putImpl() {.dirty.} =
|
||||||
template mgetOrPutImpl() {.dirty.} =
|
template mgetOrPutImpl() {.dirty.} =
|
||||||
var hc: THash
|
var hc: THash
|
||||||
var index = rawGet(t, key, hc)
|
var index = rawGet(t, key, hc)
|
||||||
if index < 0: maybeRehashPutImpl() # not present: insert
|
if index < 0: maybeRehashPutImpl() # not present: insert (flipping index)
|
||||||
result = t.data[index].val # either way return modifiable val
|
result = t.data[index].val # either way return modifiable val
|
||||||
|
|
||||||
template hasKeyOrPutImpl() {.dirty.} =
|
template hasKeyOrPutImpl() {.dirty.} =
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue