mirror of
https://github.com/nim-lang/Nim.git
synced 2026-08-24 15:41:43 +00:00
now bootstraps with -d:nimsso
This commit is contained in:
@@ -46,12 +46,11 @@ proc setToPreviousLayer*(pt: var LayeredIdTable) {.inline.} =
|
||||
when useRef:
|
||||
pt = pt.nextLayer
|
||||
else:
|
||||
when defined(gcDestructors):
|
||||
pt = pt.nextLayer[]
|
||||
else:
|
||||
# workaround refc
|
||||
let tmp = pt.nextLayer[]
|
||||
pt = tmp
|
||||
# Must read nextLayer into a temp before destroying pt:
|
||||
# `pt = pt.nextLayer[]` would call eqcopy(&pt, &(*pt.nextLayer)) which
|
||||
# decrements pt.nextLayer's rc (freeing it) before reading pt.nextLayer.nextLayer.
|
||||
let tmp = pt.nextLayer[]
|
||||
pt = tmp
|
||||
|
||||
iterator pairs*(pt: LayeredIdTable): (ItemId, PType) =
|
||||
var tm = pt
|
||||
|
||||
@@ -133,7 +133,9 @@ proc ensureUniqueLong(s: var SmallString; oldLen, newLen: int) =
|
||||
if isHeap and s.more.rc == 1 and newLen <= cap:
|
||||
s.more.fullLen = newLen
|
||||
else:
|
||||
let newCap = max(newLen, resize(cap))
|
||||
# Only grow capacity when actually needed; pure COW copies (newLen <= cap)
|
||||
# preserve the existing capacity to avoid exponential growth via repeated COW.
|
||||
let newCap = if newLen > cap: max(newLen, resize(cap)) else: cap
|
||||
let p = cast[ptr LongString](alloc(sizeof(int) * 3 + newCap + 1))
|
||||
p.rc = 1
|
||||
p.fullLen = newLen
|
||||
|
||||
Reference in New Issue
Block a user