Improve performance of duplicate code detection #574
Labels
duplicate-code
enhancement
New feature or request
high-priority
Issues that should be solved as soon as possible
perf 🏎️💨
performance
Description
The check is currently one of the slowest checks (it takes up 13.4% of execution time, second slowest check).
The problematic code sections are:
countStatements
(to decide if a code segment is long enough)occurrences
Map (that is related to the implementation ofStructuralEqualsVisitor
/StructuralHashCodeVisitor
).Here are some ideas to improve performance:
CtComment
CtStatementList
, because a single statement would not be enough for a duplicate? What is with things likeif (a) b;
?SpoonUtil.resolveConstant
#573 which should speed up theisRefactorable
method ofStructuralEqualsVisitor
. It might make sense to build up some cache like withUsesFinder
for whether variables are constant/final (I think the whole project would benefit from this).StructuralHashCodeVisitor
the slowest code is the one that callsStructuralEqualsVisitor#shouldSkip
, which should become faster with 3The text was updated successfully, but these errors were encountered: