SSO for strings (#25593)

This commit is contained in:
Andreas Rumpf
2026-04-02 07:19:43 +02:00
committed by GitHub
parent be29bcd402
commit d389d4fb2f
29 changed files with 2235 additions and 171 deletions

View File

@@ -19,7 +19,12 @@ proc addCstringN(result: var string, buf: cstring; buflen: int) =
let oldLen = result.len
let newLen = oldLen + buflen
result.setLen newLen
c_memcpy(result[oldLen].addr, buf, buflen.csize_t)
{.cast(noSideEffect).}:
when declared(completeStore):
c_memcpy(beginStore(result, buflen, oldLen), buf, buflen.csize_t)
endStore(result)
else:
discard c_memcpy(result[oldLen].addr, buf, buflen.csize_t)
import std/private/[dragonbox, schubfach]