diff options
author | Amjad Ben Hedhili <amjadhedhili@outlook.com> | 2023-09-25 06:19:09 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-25 07:19:09 +0200 |
commit | f0bf94e5311e851cba4370c2310c0be66e535a27 (patch) | |
tree | 819344abab6a70211446129a9a657daad6ef45af | |
parent | 584010196856e4c357996696e932ba0ffbc61f84 (diff) | |
download | Nim-f0bf94e5311e851cba4370c2310c0be66e535a27.tar.gz |
Make `newStringUninit` available in the VM [backport] (#22748)
It's equivalent to `newString`.
-rw-r--r-- | lib/system.nim | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/lib/system.nim b/lib/system.nim index 64412b9b3..8e16d17d4 100644 --- a/lib/system.nim +++ b/lib/system.nim @@ -1637,16 +1637,19 @@ when not defined(js): ## ## This procedure exists only for optimization purposes; ## the same effect can be achieved with the `&` operator or with `add`. - result = newStringOfCap(len) - when defined(nimSeqsV2): - let s = cast[ptr NimStringV2](addr result) - if len > 0: - s.len = len - s.p.data[len] = '\0' + when nimvm: + result = newString(len) else: - let s = cast[NimString](result) - s.len = len - s.data[len] = '\0' + result = newStringOfCap(len) + when defined(nimSeqsV2): + let s = cast[ptr NimStringV2](addr result) + if len > 0: + s.len = len + s.p.data[len] = '\0' + else: + let s = cast[NimString](result) + s.len = len + s.data[len] = '\0' else: proc newStringUninit*(len: Natural): string {. magic: "NewString", importc: "mnewString", noSideEffect.} |