From a7f302755d0c562d61b8bf023a39b92febe1dfcf Mon Sep 17 00:00:00 2001 From: Dmitry Date: Sat, 17 Jun 2023 16:46:39 +0200 Subject: [PATCH] Use EqualFold ti avoid memory reallocations --- datamodel/low/extraction_functions.go | 2 +- utils/utils.go | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/datamodel/low/extraction_functions.go b/datamodel/low/extraction_functions.go index b4cab9886..6411e87e0 100644 --- a/datamodel/low/extraction_functions.go +++ b/datamodel/low/extraction_functions.go @@ -22,7 +22,7 @@ func FindItemInMap[T any](item string, collection map[KeyReference[string]]Value if n.Value == item { return &o } - if strings.ToLower(n.Value) == strings.ToLower(item) { + if strings.EqualFold(item, n.Value) { return &o } } diff --git a/utils/utils.go b/utils/utils.go index d9c27e5d3..01342328d 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -233,7 +233,8 @@ func FindKeyNodeTop(key string, nodes []*yaml.Node) (keyNode *yaml.Node, valueNo if i%2 != 0 { continue } - if strings.ToLower(key) == strings.ToLower(v.Value) { + + if strings.EqualFold(key, v.Value) { return v, nodes[i+1] // next node is what we need. } }