From 2529b58d4db8e73af977bbb601f966d9821c2367 Mon Sep 17 00:00:00 2001 From: Yeates Date: Tue, 5 Nov 2024 13:39:47 +0800 Subject: [PATCH] refactor(secret): optimize performance by moving ToLower operation outside loop (#7862) --- pkg/fanal/secret/scanner.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/fanal/secret/scanner.go b/pkg/fanal/secret/scanner.go index 33a3806f41b4..01283ea42a46 100644 --- a/pkg/fanal/secret/scanner.go +++ b/pkg/fanal/secret/scanner.go @@ -175,9 +175,9 @@ func (r *Rule) MatchKeywords(content []byte) bool { if len(r.Keywords) == 0 { return true } - + var contentLower = bytes.ToLower(content) for _, kw := range r.Keywords { - if bytes.Contains(bytes.ToLower(content), []byte(strings.ToLower(kw))) { + if bytes.Contains(contentLower, []byte(strings.ToLower(kw))) { return true } }