use typeof instead type (#16962)

This commit is contained in:
flywind 2021-02-08 02:46:07 -06:00 • committed by GitHub
commit d447c0fe3f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
31 changed files with 253 additions and 253 deletions

View file

@ -86,7 +86,7 @@ proc exclImpl[A](s: var HashSet[A], key: A): bool {.inline.} =
var j = i # The correctness of this depends on (h+1) in nextTry,
var r = j # though may be adaptable to other simple sequences.
s.data[i].hcode = 0 # mark current EMPTY
s.data[i].key = default(type(s.data[i].key))
s.data[i].key = default(typeof(s.data[i].key))
doWhile((i >= r and r > j) or (r > j and j > i) or (j > i and i >= r)):
i = (i + 1) and msk # increment mod table size
if isEmpty(s.data[i].hcode): # end of collision cluster; So all done

View file

@ -355,7 +355,7 @@ proc clear*[A](s: var HashSet[A]) =
s.counter = 0
for i in 0 ..< s.data.len:
s.data[i].hcode = 0
s.data[i].key = default(type(s.data[i].key))
s.data[i].key = default(typeof(s.data[i].key))
proc len*[A](s: HashSet[A]): int =
## Returns the number of elements in `s`.
@ -812,7 +812,7 @@ proc clear*[A](s: var OrderedSet[A]) =
for i in 0 ..< s.data.len:
s.data[i].hcode = 0
s.data[i].next = 0
s.data[i].key = default(type(s.data[i].key))
s.data[i].key = default(typeof(s.data[i].key))
proc len*[A](s: OrderedSet[A]): int {.inline.} =
## Returns the number of elements in `s`.

View file

@ -117,8 +117,8 @@ template delImplIdx(t, i, makeEmpty, cellEmpty, cellHash) =
var j = i # The correctness of this depends on (h+1) in nextTry
var r = j # though may be adaptable to other simple sequences.
makeEmpty(i) # mark current EMPTY
t.data[i].key = default(type(t.data[i].key))
t.data[i].val = default(type(t.data[i].val))
t.data[i].key = default(typeof(t.data[i].key))
t.data[i].val = default(typeof(t.data[i].val))
while true:
i = (i + 1) and msk # increment mod table size
if cellEmpty(i): # end of collision cluster; So all done
@ -149,8 +149,8 @@ template clearImpl() {.dirty.} =
for i in 0 ..< t.dataLen:
when compiles(t.data[i].hcode): # CountTable records don't contain a hcode
t.data[i].hcode = 0
t.data[i].key = default(type(t.data[i].key))
t.data[i].val = default(type(t.data[i].val))
t.data[i].key = default(typeof(t.data[i].key))
t.data[i].val = default(typeof(t.data[i].val))
t.counter = 0
template ctAnd(a, b): bool =
@ -161,7 +161,7 @@ template ctAnd(a, b): bool =
template initImpl(result: typed, size: int) =
let correctSize = slotsNeeded(size)
when ctAnd(declared(SharedTable), type(result) is SharedTable):
when ctAnd(declared(SharedTable), typeof(result) is SharedTable):
init(result, correctSize)
else:
result.counter = 0