From a44dc542ba852c6a1c107b65e20073a7e4da8999 Mon Sep 17 00:00:00 2001 From: Saad Hussain Date: Fri, 9 Oct 2026 11:30:20 -0400 Subject: [PATCH] perf(graph): use strings.IndexByte instead of strings.Contains for single char --- pkg/go/graph/weighted_graph.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/go/graph/weighted_graph.go b/pkg/go/graph/weighted_graph.go index 77ea3c8a..74f7b644 100644 --- a/pkg/go/graph/weighted_graph.go +++ b/pkg/go/graph/weighted_graph.go @@ -251,7 +251,7 @@ func (wg *WeightedAuthorizationModelGraph) GetNodeWeight(node *WeightedAuthoriza return 0, false } - if strings.Contains(key, "#") { + if strings.IndexByte(key, '#') >= 0 { // If the key contains a "#", it is a SpecificTypeAndRelation // We need to find the base type (the part before the "#") return wg.getWeightForUserset(node, key) @@ -266,7 +266,7 @@ func (wg *WeightedAuthorizationModelGraph) GetEdgeWeight(edge *WeightedAuthoriza return 0, false } - if !strings.Contains(key, "#") { + if strings.IndexByte(key, '#') < 0 { return edge.GetWeight(key) }