mirror of https://github.com/status-im/NimYAML.git
fix for --gc:orc; some memory improvements
This commit is contained in:
parent
a053947f53
commit
f123924d32
|
@ -448,7 +448,7 @@ proc atBlockIndentationProps(c: Context, e: var Event): bool =
|
||||||
if c.lex.cur == Token.MapValueInd:
|
if c.lex.cur == Token.MapValueInd:
|
||||||
if c.lex.lastScalarWasMultiline():
|
if c.lex.lastScalarWasMultiline():
|
||||||
raise c.generateError("Implicit mapping key may not be multiline")
|
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)
|
e = startMapEvent(csBlock, c.headerProps, c.headerStart, headerEnd)
|
||||||
c.headerProps = defaultProperties
|
c.headerProps = defaultProperties
|
||||||
c.transition(afterImplicitKey)
|
c.transition(afterImplicitKey)
|
||||||
|
@ -502,7 +502,7 @@ proc beforeNodeProperties(c: Context, e: var Event): bool =
|
||||||
of VerbatimTag:
|
of VerbatimTag:
|
||||||
if c.inlineProps.tag != yTagQuestionMark:
|
if c.inlineProps.tag != yTagQuestionMark:
|
||||||
raise c.generateError("Only one tag allowed per node")
|
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:
|
of Token.Anchor:
|
||||||
if c.inlineProps.anchor != yAnchorNone:
|
if c.inlineProps.anchor != yAnchorNone:
|
||||||
raise c.generateError("Only one anchor allowed per node")
|
raise c.generateError("Only one anchor allowed per node")
|
||||||
|
|
|
@ -53,7 +53,7 @@ proc nextAnchor*(s: var string, i: int) =
|
||||||
s[i] = 'a'
|
s[i] = 'a'
|
||||||
nextAnchor(s, i - 1)
|
nextAnchor(s, i - 1)
|
||||||
else:
|
else:
|
||||||
inc(s[i])
|
s[i] = char(int(s[i]) + 1)
|
||||||
|
|
||||||
template resetHandles*(handles: var seq[tuple[handle, uriPrefix: string]]) {.dirty.} =
|
template resetHandles*(handles: var seq[tuple[handle, uriPrefix: string]]) {.dirty.} =
|
||||||
handles.setLen(0)
|
handles.setLen(0)
|
||||||
|
|
|
@ -414,7 +414,7 @@ proc constructObject*[T](s: var YamlStream, c: ConstructionContext,
|
||||||
while s.peek().kind != yamlEndSeq:
|
while s.peek().kind != yamlEndSeq:
|
||||||
var item: T
|
var item: T
|
||||||
constructChild(s, c, item)
|
constructChild(s, c, item)
|
||||||
result.add(item)
|
result.add(move(item))
|
||||||
discard s.next()
|
discard s.next()
|
||||||
|
|
||||||
proc constructObject*[T](s: var YamlStream, c: ConstructionContext,
|
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)
|
raise s.constructionError(event.startPos, "Expected map end, got " & $event.kind)
|
||||||
if result.contains(key):
|
if result.contains(key):
|
||||||
raise s.constructionError(event.startPos, "Duplicate table key!")
|
raise s.constructionError(event.startPos, "Duplicate table key!")
|
||||||
result.add(key, value)
|
result[move(key)] = move(value)
|
||||||
discard s.next()
|
discard s.next()
|
||||||
|
|
||||||
proc representObject*[K, V](value: OrderedTable[K, V], ts: TagStyle,
|
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:
|
if value.isSome:
|
||||||
representChild(value.get(), ts, c)
|
representChild(value.get(), ts, c)
|
||||||
else:
|
else:
|
||||||
let childTagStyle = if ts == tsRootOnly: tsNone else: ts
|
|
||||||
c.put(scalarEvent("~", yTagNull))
|
c.put(scalarEvent("~", yTagNull))
|
||||||
|
|
||||||
proc representChild*[O](value: O, ts: TagStyle,
|
proc representChild*[O](value: O, ts: TagStyle,
|
||||||
|
@ -1324,7 +1323,7 @@ proc construct*[T](s: var YamlStream, target: var T)
|
||||||
raise (ref YamlConstructionError)(getCurrentException())
|
raise (ref YamlConstructionError)(getCurrentException())
|
||||||
except YamlStreamError:
|
except YamlStreamError:
|
||||||
let cur = getCurrentException()
|
let cur = getCurrentException()
|
||||||
var e = newException(YamlStreamError, cur.msg)
|
var e = newException(YamlStreamError, move(cur.msg))
|
||||||
e.parent = cur.parent
|
e.parent = cur.parent
|
||||||
raise e
|
raise e
|
||||||
except Exception:
|
except Exception:
|
||||||
|
|
Loading…
Reference in New Issue