mirror of
https://github.com/mikefarah/yq.git
synced 2025-01-12 19:25:37 +00:00
Slight performance improvement to context.ChildContext
This commit is contained in:
parent
4a4aae00af
commit
79bc1f95cb
@ -43,11 +43,14 @@ func (n *Context) SetVariable(name string, value *list.List) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (n *Context) ChildContext(results *list.List) Context {
|
func (n *Context) ChildContext(results *list.List) Context {
|
||||||
clone := Context{}
|
clone := Context{DontAutoCreate: n.DontAutoCreate}
|
||||||
err := copier.Copy(&clone, n)
|
clone.Variables = make(map[string]*list.List)
|
||||||
if err != nil {
|
if len(n.Variables) > 0 {
|
||||||
log.Error("Error cloning context :(")
|
err := copier.Copy(&clone.Variables, n.Variables)
|
||||||
panic(err)
|
if err != nil {
|
||||||
|
log.Error("Error cloning context :(")
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
clone.MatchingNodes = results
|
clone.MatchingNodes = results
|
||||||
return clone
|
return clone
|
||||||
|
Loading…
Reference in New Issue
Block a user