replace shallowcopy with move in ARC/ORC (#20061)

This commit is contained in:
flywind
2022-07-19 03:23:39 +08:00
committed by GitHub
parent 2549d398a9
commit d934ba9326

View File

@@ -218,10 +218,6 @@ proc newJRawNumber(s: string): JsonNode =
## to the string representation without the quotes.
result = JsonNode(kind: JString, str: s, isUnquoted: true)
proc newJStringMove(s: string): JsonNode =
result = JsonNode(kind: JString)
shallowCopy(result.str, s)
proc newJInt*(n: BiggestInt): JsonNode =
## Creates a new `JInt JsonNode`.
result = JsonNode(kind: JInt, num: n)
@@ -859,8 +855,12 @@ proc parseJson(p: var JsonParser; rawIntegers, rawFloats: bool, depth = 0): Json
case p.tok
of tkString:
# we capture 'p.a' here, so we need to give it a fresh buffer afterwards:
result = newJStringMove(p.a)
p.a = ""
when defined(gcArc) or defined(gcOrc):
result = JsonNode(kind: JString, str: move p.a)
else:
result = JsonNode(kind: JString)
shallowCopy(result.str, p.a)
p.a = ""
discard getTok(p)
of tkInt:
if rawIntegers: