From 053949eac6b967354abffc5777e837b602c3fb5a Mon Sep 17 00:00:00 2001 From: Dmytro Maluka Date: Sat, 23 Mar 2024 21:59:40 +0100 Subject: [PATCH] UpdateRules: de-densify code arouns signatureMatch Purely cosmetic change: make the code a bit more readable by reducing its visual "density". --- internal/buffer/buffer.go | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/internal/buffer/buffer.go b/internal/buffer/buffer.go index 91cfa429..ecdc90e1 100644 --- a/internal/buffer/buffer.go +++ b/internal/buffer/buffer.go @@ -810,17 +810,20 @@ func (b *Buffer) UpdateRules() { if detectlimit > 0 && lineCount > detectlimit { limit = detectlimit } - for i := 0; i < length && !signatureMatch; i++ { - if matches[i].header.HasFileSignature() { - for j := 0; j < limit && !signatureMatch; j++ { - if matches[i].header.MatchFileSignature(b.lines[j].data) { - syntaxFile = matches[i].fileName - if matches[i].syntaxDef != nil { - b.SyntaxDef = matches[i].syntaxDef + + matchLoop: + for _, m := range matches { + if m.header.HasFileSignature() { + for i := 0; i < limit; i++ { + if m.header.MatchFileSignature(b.lines[i].data) { + syntaxFile = m.fileName + if m.syntaxDef != nil { + b.SyntaxDef = m.syntaxDef foundDef = true } - header = matches[i].header + header = m.header signatureMatch = true + break matchLoop } } }