Add compute proc for SharedTable (#5385)

This commit is contained in:
Ruslan Mustakov 2017-03-02 21:31:30 +07:00 • committed by Andreas Rumpf
commit a81247dcbe
3 changed files with 77 additions and 4 deletions

View file

@ -120,9 +120,7 @@ template default[T](t: typedesc[T]): T =
var v: T
v
template delImpl() {.dirty.} =
var hc: Hash
var i = rawGet(t, key, hc)
template delImplIdx(t, i) =
let msk = maxHash(t)
if i >= 0:
dec(t.counter)
@ -145,6 +143,11 @@ template delImpl() {.dirty.} =
else:
shallowCopy(t.data[j], t.data[i]) # data[j] will be marked EMPTY next loop
template delImpl() {.dirty.} =
var hc: Hash
var i = rawGet(t, key, hc)
delImplIdx(t, i)
template clearImpl() {.dirty.} =
for i in 0 .. <t.data.len:
when compiles(t.data[i].hcode): # CountTable records don't contain a hcode