fix for --gc:orc; some memory improvements

This commit is contained in:
Felix Krause 2021-05-17 23:51:35 +02:00
parent a053947f53
commit f123924d32
3 changed files with 6 additions and 7 deletions

View File

@ -448,7 +448,7 @@ proc atBlockIndentationProps(c: Context, e: var Event): bool =
if c.lex.cur == Token.MapValueInd:
if c.lex.lastScalarWasMultiline():
raise c.generateError("Implicit mapping key may not be multiline")
c.keyCache.add(e)
c.keyCache.add(move(e))
e = startMapEvent(csBlock, c.headerProps, c.headerStart, headerEnd)
c.headerProps = defaultProperties
c.transition(afterImplicitKey)
@ -502,7 +502,7 @@ proc beforeNodeProperties(c: Context, e: var Event): bool =
of VerbatimTag:
if c.inlineProps.tag != yTagQuestionMark:
raise c.generateError("Only one tag allowed per node")
c.inlineProps.tag = Tag(c.lex.evaluated)
c.inlineProps.tag = Tag(move(c.lex.evaluated))
of Token.Anchor:
if c.inlineProps.anchor != yAnchorNone:
raise c.generateError("Only one anchor allowed per node")

View File

@ -53,7 +53,7 @@ proc nextAnchor*(s: var string, i: int) =
s[i] = 'a'
nextAnchor(s, i - 1)
else:
inc(s[i])
s[i] = char(int(s[i]) + 1)
template resetHandles*(handles: var seq[tuple[handle, uriPrefix: string]]) {.dirty.} =
handles.setLen(0)

View File

@ -414,7 +414,7 @@ proc constructObject*[T](s: var YamlStream, c: ConstructionContext,
while s.peek().kind != yamlEndSeq:
var item: T
constructChild(s, c, item)
result.add(item)
result.add(move(item))
discard s.next()
proc constructObject*[T](s: var YamlStream, c: ConstructionContext,
@ -530,7 +530,7 @@ proc constructObject*[K, V](s: var YamlStream, c: ConstructionContext,
raise s.constructionError(event.startPos, "Expected map end, got " & $event.kind)
if result.contains(key):
raise s.constructionError(event.startPos, "Duplicate table key!")
result.add(key, value)
result[move(key)] = move(value)
discard s.next()
proc representObject*[K, V](value: OrderedTable[K, V], ts: TagStyle,
@ -1292,7 +1292,6 @@ proc representChild*[T](value: Option[T], ts: TagStyle,
if value.isSome:
representChild(value.get(), ts, c)
else:
let childTagStyle = if ts == tsRootOnly: tsNone else: ts
c.put(scalarEvent("~", yTagNull))
proc representChild*[O](value: O, ts: TagStyle,
@ -1324,7 +1323,7 @@ proc construct*[T](s: var YamlStream, target: var T)
raise (ref YamlConstructionError)(getCurrentException())
except YamlStreamError:
let cur = getCurrentException()
var e = newException(YamlStreamError, cur.msg)
var e = newException(YamlStreamError, move(cur.msg))
e.parent = cur.parent
raise e
except Exception: