1
0
mirror of https://github.com/mgechev/revive.git synced 2025-02-03 13:11:25 +02:00

speedup branch comparison (#764)

This commit is contained in:
chavacava 2022-10-24 17:21:48 +02:00 committed by GitHub
parent 55e881a792
commit 06881a9f54
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -63,8 +63,10 @@ func (lintIdenticalBranches) identicalBranches(branches []*ast.BlockStmt) bool {
}
ref := gofmt(branches[0])
refSize := len(branches[0].List)
for i := 1; i < len(branches); i++ {
if gofmt(branches[i]) != ref {
currentSize := len(branches[i].List)
if currentSize != refSize || gofmt(branches[i]) != ref {
return false
}
}