Fix 2 Eclipse warnings about useless instanceof checks
Effectively these two checks could only be false if the instance being
tested were null. So we replace the instanceof checks with null
checks. Sometimes that, in turn, makes other surrounding code
simpler. In the case of ApplicationLoaderFilter.test, for example,
a whole conditional case ("o instanceof LocalPointerKey") becomes
statically impossible. That seems a bit strange to me, but that's
what the code was effectively doing.
This commit is contained in:
parent
934f8f524f
commit
94fcc3966f
@ -198,15 +198,9 @@ public class PDFCallGraph {
|
||||
private static class ApplicationLoaderFilter extends Predicate<CGNode> {
|
||||
|
||||
@Override public boolean test(CGNode o) {
|
||||
if (o instanceof CGNode) {
|
||||
CGNode n = (CGNode) o;
|
||||
return n.getMethod().getDeclaringClass().getClassLoader().getReference().equals(ClassLoaderReference.Application);
|
||||
} else if (o instanceof LocalPointerKey) {
|
||||
LocalPointerKey l = (LocalPointerKey) o;
|
||||
return test(l.getNode());
|
||||
} else {
|
||||
if (o == null)
|
||||
return false;
|
||||
}
|
||||
return o.getMethod().getDeclaringClass().getClassLoader().getReference().equals(ClassLoaderReference.Application);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -261,7 +261,7 @@ public class DefaultFixedPointSystem<T extends IVariable<?>> implements IFixedPo
|
||||
public Iterator<T> getVariables() {
|
||||
return new FilterIterator<>(graph.iterator(), new Predicate<T>() {
|
||||
@Override public boolean test(T x) {
|
||||
return x instanceof IVariable;
|
||||
return x != null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user