If you have x == 1 || x == 2 || x == 3 || x == 4, the pass considered the set {x==1, x==2, x==3, x==4} and then also {x==2, x==3, x==4} {x==3, x==4} Since the comparison is itself linear in the size of the set, this was overall taking time quadratic in the length of the || or && sequence. Worse, if it found duplicates, they'd be reported a quadratic number of times. This CL cuts the time and output to linear by avoiding already-checked subexpressions. This cuts the time spent analyzing cmd/compile/internal/ssa (with all passes enabled, not just this one) by 20%. Fixes golang/go#28086. Change-Id: I812f64bd5a44fea995c9ab0c4fa2fbefb44037ce Reviewed-on: https://go-review.googlesource.com/c/tools/+/176457 Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Rob Pike <r@golang.org> Reviewed-by: Alan Donovan <adonovan@google.com> |
||
---|---|---|
.. | ||
asmdecl | ||
assign | ||
atomic | ||
atomicalign | ||
bools | ||
buildssa | ||
buildtag | ||
cgocall | ||
composite | ||
copylock | ||
ctrlflow | ||
deepequalerrors | ||
errorsas | ||
findcall | ||
httpresponse | ||
inspect | ||
internal/analysisutil | ||
loopclosure | ||
lostcancel | ||
nilfunc | ||
nilness | ||
pkgfact | ||
printf | ||
shadow | ||
shift | ||
stdmethods | ||
structtag | ||
tests | ||
unmarshal | ||
unreachable | ||
unsafeptr | ||
unusedresult | ||
README |
README
This directory does not contain a Go package, but acts as a container for various analyses that implement the golang.org/x/tools/go/analysis API and may be imported into an analysis tool. By convention, each package foo provides the analysis, and each command foo/cmd/foo provides a standalone driver.