This commit is contained in:
araq
2026-03-11 17:02:51 +01:00
parent 31184621df
commit a2b0f9e2c6
2 changed files with 4 additions and 1 deletions

View File

@@ -460,7 +460,9 @@ proc addInt128*(result: var string; value: Int128) =
var i = initialSize
var j = high(result)
while i < j:
swap(result[i], result[j])
let tmp = result[i]
result[i] = result[j]
result[j] = tmp
i += 1
j -= 1

View File

@@ -574,6 +574,7 @@ proc setLengthStrV2(s: var SmallString; newLen: int) {.compilerRtl.} =
proc nimAsgnStrV2(a: var SmallString; b: SmallString) {.compilerRtl, inline.} =
if ssLen(b) <= PayloadSize:
nimDestroyStrV1(a) # free any existing heap block before overwriting
copyMem(addr a, unsafeAddr b, sizeof(SmallString))
else:
if addr(a) == unsafeAddr(b): return