From ed3c29be12df0ac81e9cba417bb3d3d01e28bfb7 Mon Sep 17 00:00:00 2001 From: Richard Marshall Date: Tue, 23 Jul 2019 23:48:26 -0700 Subject: [PATCH] Simplify name reference candidate resmap building This patch removes a layer of looping in the name reference candiate resmap building process by not checking if the resources already exist in the new resmap. --- pkg/resmap/resmap.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/pkg/resmap/resmap.go b/pkg/resmap/resmap.go index 5e0b3b653..58e42ac00 100644 --- a/pkg/resmap/resmap.go +++ b/pkg/resmap/resmap.go @@ -552,7 +552,7 @@ func (m *resWrangler) makeCopy(copier resCopier) ResMap { // SubsetThatCouldBeReferencedByResource implements ResMap. func (m *resWrangler) SubsetThatCouldBeReferencedByResource( inputRes *resource.Resource) ResMap { - result := New() + result := newOne() inputId := inputRes.CurId() isInputIdNamespaceable := inputId.IsNamespaceableKind() rctxm := inputRes.PrefixesSuffixesEquals @@ -563,15 +563,16 @@ func (m *resWrangler) SubsetThatCouldBeReferencedByResource( resId := r.CurId() if (!isInputIdNamespaceable || !resId.IsNamespaceableKind() || resId.IsNsEquals(inputId)) && r.InSameKustomizeCtx(rctxm) { - err := result.Append(r) - if err != nil { - panic(err) - } + result.append(r) } } return result } +func (m *resWrangler) append(res *resource.Resource) { + m.rList = append(m.rList, res) +} + // AppendAll implements ResMap. func (m *resWrangler) AppendAll(other ResMap) error { if other == nil {