Skip to content

Instantly share code, notes, and snippets.

@nitely
Last active June 8, 2024 02:06
Show Gist options
  • Save nitely/30334fca30370cb095fc6117373e681b to your computer and use it in GitHub Desktop.
Save nitely/30334fca30370cb095fc6117373e681b to your computer and use it in GitHub Desktop.
func add*(s: var seq[byte], ss: openArray[char]) {.raises: [].} =
if ss.len == 0: return
let L = s.len
when nimvm:
s.setLen(L+ss.len)
for i in 0 .. ss.len-1:
s[L+i] = ss[i].byte
else:
#when defined(orc):
# s.setLenUninit(L+ss.len)
#else:
s.setLen(L+ss.len)
moveMem(addr s[L], unsafeAddr ss[0], ss.len)
func add*(s: var string, ss: openArray[byte]) {.raises: [].} =
if ss.len == 0: return
let L = s.len
when nimvm:
s.setLen(L+ss.len)
for i in 0 .. ss.len-1:
s[L+i] = ss[i].char
else:
s.setLen(L+ss.len)
prepareMutation(s)
moveMem(addr s[L], unsafeAddr ss[0], ss.len)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment