better beginStore API

This commit is contained in:
Araq
2026-04-27 00:39:32 +02:00
parent 5caa22edc3
commit 49b1532620
7 changed files with 49 additions and 25 deletions

View File

@@ -18,12 +18,12 @@ proc addCstringN(result: var string, buf: cstring; buflen: int) =
# no nimvm support needed, so it doesn't need to be fast here either
let oldLen = result.len
let newLen = oldLen + buflen
result.setLen newLen
{.cast(noSideEffect).}:
when declared(completeStore):
c_memcpy(beginStore(result, buflen, oldLen), buf, buflen.csize_t)
when declared(beginStore):
c_memcpy(beginStore(result, newLen, oldLen), buf, buflen.csize_t)
endStore(result)
else:
result.setLen newLen
discard c_memcpy(result[oldLen].addr, buf, buflen.csize_t)
import std/private/[dragonbox, schubfach]