perf: eliminate unnecessary RNode creation

This commit is contained in:
Ed Overton
2023-05-02 13:15:01 -04:00
parent ee3f506d10
commit 97c8cd7d1a

View File

@@ -450,15 +450,13 @@ func (rn *RNode) getMetaData() *yaml.Node {
if IsMissingOrNull(rn) { if IsMissingOrNull(rn) {
return nil return nil
} }
var n *RNode content := rn.Content()
if rn.YNode().Kind == DocumentNode { if rn.YNode().Kind == DocumentNode {
// get the content if this is the document node // get the content if this is the document node
n = NewRNode(rn.Content()[0]) content = content[0].Content
} else {
n = rn
} }
var mf *yaml.Node var mf *yaml.Node
visitMappingNodeFields(n.Content(), func(key, value *yaml.Node) { visitMappingNodeFields(content, func(key, value *yaml.Node) {
if !IsYNodeNilOrEmpty(value) { if !IsYNodeNilOrEmpty(value) {
mf = value mf = value
} }