From acbec053c985388a26d899e73b4b7f5a6d1fa210 Mon Sep 17 00:00:00 2001 From: Paul Cacheux Date: Tue, 2 Jul 2024 08:11:09 +0200 Subject: [PATCH] perf(debian): use `bytes.Index` in `emptyLineSplit` to cut allocation (#7065) --- pkg/fanal/analyzer/pkg/dpkg/scanner.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkg/fanal/analyzer/pkg/dpkg/scanner.go b/pkg/fanal/analyzer/pkg/dpkg/scanner.go index 2e38f06b0cf7..d29fe951f652 100644 --- a/pkg/fanal/analyzer/pkg/dpkg/scanner.go +++ b/pkg/fanal/analyzer/pkg/dpkg/scanner.go @@ -5,7 +5,6 @@ import ( "bytes" "io" "net/textproto" - "strings" ) type dpkgScanner struct { @@ -42,7 +41,7 @@ func emptyLineSplit(data []byte, atEOF bool) (advance int, token []byte, err err return 0, nil, nil } - if i := strings.Index(string(data), "\n\n"); i >= 0 { + if i := bytes.Index(data, []byte("\n\n")); i >= 0 { // We have a full empty line terminated block. return i + 2, data[0:i], nil }