Skip to content

Commit

Permalink
improve for each filter performance
Browse files Browse the repository at this point in the history
Hack to avoid nfa degraded performance when large methods were present
as it prevented use of the cache.
  • Loading branch information
hcoles committed Mar 23, 2023
1 parent 18eb03c commit f9af9d8
Showing 1 changed file with 0 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,6 @@ private Predicate<MutationDetails> mutatesIteratorLoopPlumbing() {
final int instruction = a.getInstructionIndex();
final MethodTree method = currentClass.method(a.getId().getLocation()).get();

//performance hack
if (!mightContainForLoop(method.instructions())) {
return false;
}

final AbstractInsnNode mutatedInstruction = method.instruction(instruction);

Set<AbstractInsnNode> toAvoid = cache.computeIfAbsent(method, this::findLoopInstructions);
Expand All @@ -211,11 +206,6 @@ private Set<AbstractInsnNode> findLoopInstructions(MethodTree method) {
.collect(Collectors.toSet());
}

private boolean mightContainForLoop(List<AbstractInsnNode> instructions) {
return instructions.stream()
.anyMatch(hasNextMethodCall().or(ARRAYLENGTH).asPredicate());
}

@Override
public void end() {
this.currentClass = null;
Expand Down

0 comments on commit f9af9d8

Please sign in to comment.