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)
Building the occurrences Map (that is related to the implementation of StructuralEqualsVisitor/StructuralHashCodeVisitor).
Here are some ideas to improve performance:
Skip adding more kinds of statements in the occurrences map like CtComment
Only add multiple statements to the occurrences map like CtStatementList, because a single statement would not be enough for a duplicate? What is with things like if (a) b;?
Implement #573 which should speed up the isRefactorable method of StructuralEqualsVisitor. It might make sense to build up some cache like with UsesFinder for whether variables are constant/final (I think the whole project would benefit from this).
For StructuralHashCodeVisitor the slowest code is the one that calls StructuralEqualsVisitor#shouldSkip, which should become faster with 3
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;
?isRefactorable
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 3