Skip to content

Commit 8861260

Browse files
committed
perf: optimize isKROReservedWord function
Replace linear search through reservedKeyWords.List() with direct set lookup using Has() method for better performance when validating reserved world in kro.
1 parent 64da0cb commit 8861260

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

pkg/graph/validation.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,7 @@ func isValidKindName(name string) bool {
9898

9999
// isKROReservedWord checks if the given word is a reserved word in KRO.
100100
func isKROReservedWord(word string) bool {
101-
for _, w := range reservedKeyWords.List() {
102-
if w == word {
103-
return true
104-
}
105-
}
106-
return false
101+
return reservedKeyWords.Has(word)
107102
}
108103

109104
// validateResourceGraphDefinitionNamingConventions validates the naming conventions of

0 commit comments

Comments
 (0)