refactor: use strings.FieldsFuncSeq to reduce memory allocations

Signed-off-by: juejinyuxitu <juejinyuxitu@outlook.com>
This commit is contained in:
juejinyuxitu 2025-09-24 23:11:17 +08:00
parent 07ccec116d
commit f5cf156af1

View file

@ -250,7 +250,7 @@ func printContent(io *iostreams.IOStreams, gists []shared.Gist, filter *regexp.R
}
if file.Content != "" {
for _, line := range strings.FieldsFunc(file.Content, split) {
for line := range strings.FieldsFuncSeq(file.Content, split) {
if filter.MatchString(line) {
if line, err = highlightMatch(line, filter, &matched, normal, cs.Highlight); err != nil {
return err