deprecate the .this pragma
This commit is contained in:
parent
babd31360a
commit
b4e5c9d075
5 changed files with 48 additions and 51 deletions
|
|
@ -30,14 +30,7 @@ type
|
|||
wordCounter: int
|
||||
idAnon*, idDelegator*, emptyIdent*: PIdent
|
||||
|
||||
when false:
|
||||
var
|
||||
legacy: IdentCache
|
||||
|
||||
proc resetIdentCache*() =
|
||||
when false:
|
||||
for i in low(legacy.buckets)..high(legacy.buckets):
|
||||
legacy.buckets[i] = nil
|
||||
proc resetIdentCache*() = discard
|
||||
|
||||
proc cmpIgnoreStyle*(a, b: cstring, blen: int): int =
|
||||
if a[0] != b[0]: return 1
|
||||
|
|
@ -73,11 +66,9 @@ proc cmpExact(a, b: cstring, blen: int): int =
|
|||
if result == 0:
|
||||
if a[i] != '\0': result = 1
|
||||
|
||||
{.this: self.}
|
||||
|
||||
proc getIdent*(self: IdentCache; identifier: cstring, length: int, h: Hash): PIdent =
|
||||
var idx = h and high(buckets)
|
||||
result = buckets[idx]
|
||||
proc getIdent*(ic: IdentCache; identifier: cstring, length: int, h: Hash): PIdent =
|
||||
var idx = h and high(ic.buckets)
|
||||
result = ic.buckets[idx]
|
||||
var last: PIdent = nil
|
||||
var id = 0
|
||||
while result != nil:
|
||||
|
|
@ -85,8 +76,8 @@ proc getIdent*(self: IdentCache; identifier: cstring, length: int, h: Hash): PId
|
|||
if last != nil:
|
||||
# make access to last looked up identifier faster:
|
||||
last.next = result.next
|
||||
result.next = buckets[idx]
|
||||
buckets[idx] = result
|
||||
result.next = ic.buckets[idx]
|
||||
ic.buckets[idx] = result
|
||||
return
|
||||
elif cmpIgnoreStyle(cstring(result.s), identifier, length) == 0:
|
||||
assert((id == 0) or (id == result.id))
|
||||
|
|
@ -97,20 +88,20 @@ proc getIdent*(self: IdentCache; identifier: cstring, length: int, h: Hash): PId
|
|||
result.h = h
|
||||
result.s = newString(length)
|
||||
for i in countup(0, length - 1): result.s[i] = identifier[i]
|
||||
result.next = buckets[idx]
|
||||
buckets[idx] = result
|
||||
result.next = ic.buckets[idx]
|
||||
ic.buckets[idx] = result
|
||||
if id == 0:
|
||||
inc(wordCounter)
|
||||
result.id = -wordCounter
|
||||
inc(ic.wordCounter)
|
||||
result.id = -ic.wordCounter
|
||||
else:
|
||||
result.id = id
|
||||
|
||||
proc getIdent*(self: IdentCache; identifier: string): PIdent =
|
||||
result = getIdent(cstring(identifier), len(identifier),
|
||||
proc getIdent*(ic: IdentCache; identifier: string): PIdent =
|
||||
result = getIdent(ic, cstring(identifier), len(identifier),
|
||||
hashIgnoreStyle(identifier))
|
||||
|
||||
proc getIdent*(self: IdentCache; identifier: string, h: Hash): PIdent =
|
||||
result = getIdent(cstring(identifier), len(identifier), h)
|
||||
proc getIdent*(ic: IdentCache; identifier: string, h: Hash): PIdent =
|
||||
result = getIdent(ic, cstring(identifier), len(identifier), h)
|
||||
|
||||
proc newIdentCache*(): IdentCache =
|
||||
result = IdentCache()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue