Commit 9412ed77 authored by Jason Zaugg's avatar Jason Zaugg
Browse files

Short circuit instruction set containsAll based on set size

parent c72a86bd
...@@ -201,7 +201,7 @@ public class SourceInterpreter extends Interpreter<SourceValue> implements Opcod ...@@ -201,7 +201,7 @@ public class SourceInterpreter extends Interpreter<SourceValue> implements Opcod
return new SourceValue(Math.min(value1.size, value2.size), setUnion); return new SourceValue(Math.min(value1.size, value2.size), setUnion);
} }
} }
if (value1.size != value2.size || !value1.insns.containsAll(value2.insns)) { if (value1.size != value2.size || !containsAll(value1.insns, value2.insns)) {
HashSet<AbstractInsnNode> setUnion = new HashSet<AbstractInsnNode>(); HashSet<AbstractInsnNode> setUnion = new HashSet<AbstractInsnNode>();
setUnion.addAll(value1.insns); setUnion.addAll(value1.insns);
setUnion.addAll(value2.insns); setUnion.addAll(value2.insns);
...@@ -209,4 +209,9 @@ public class SourceInterpreter extends Interpreter<SourceValue> implements Opcod ...@@ -209,4 +209,9 @@ public class SourceInterpreter extends Interpreter<SourceValue> implements Opcod
} }
return value1; return value1;
} }
private static <A> boolean containsAll(Set<A> self, Set<A> other) {
if (self.size() < other.size()) return false;
return self.containsAll(other);
}
} }
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment