Merge pull request #5155 from ephesused/eliminate-unnecessary-rnode

perf: eliminate unnecessary RNode creation
This commit is contained in:
Kubernetes Prow Robot
2023-05-09 15:27:55 -07:00
committed by GitHub

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
} }