Last active
June 8, 2024 02:06
-
-
Save nitely/30334fca30370cb095fc6117373e681b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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