Merge pull request #6840 from aschackmull/java/misc-perf

Java: Fix some performance issues.
This commit is contained in:
Anders Schack-Mulligen
2021-10-13 15:53:49 +02:00
committed by GitHub
3 changed files with 11 additions and 5 deletions

View File

@@ -30,7 +30,7 @@ predicate containsSpecialCollection(Expr e, SpecialCollectionCreation origin) {
e = origin
or
exists(Variable v |
containsSpecialCollection(v.getAnAssignedValue(), origin) and
containsSpecialCollection(pragma[only_bind_into](v.getAnAssignedValue()), origin) and
e = v.getAnAccess()
)
or
@@ -52,7 +52,7 @@ predicate iterOfSpecialCollection(Expr e, SpecialCollectionCreation origin) {
)
or
exists(Variable v |
iterOfSpecialCollection(v.getAnAssignedValue(), origin) and
iterOfSpecialCollection(pragma[only_bind_into](v.getAnAssignedValue()), origin) and
e = v.getAnAccess()
)
or

View File

@@ -41,10 +41,9 @@ class StringValue extends Expr {
}
}
predicate variableValuesInterned(Variable v) {
pragma[noinline]
predicate candidateVariable(Variable v) {
v.fromSource() and
// All assignments to variables are interned.
forall(StringValue sv | sv = v.getAnAssignedValue() | sv.isInterned()) and
// For parameters, assume they could be non-interned.
not v instanceof Parameter and
// If the string is modified with `+=`, then the new string is not interned
@@ -52,6 +51,12 @@ predicate variableValuesInterned(Variable v) {
not exists(AssignOp append | append.getDest() = v.getAnAccess())
}
predicate variableValuesInterned(Variable v) {
candidateVariable(v) and
// All assignments to variables are interned.
forall(StringValue sv | sv = v.getAnAssignedValue() | sv.isInterned())
}
from EqualityTest e, StringValue lhs, StringValue rhs
where
e.getLeftOperand() = lhs and

View File

@@ -17,6 +17,7 @@ import java
* since package-protected fields are not inherited by classes in different
* packages, but it's enough for the purposes of this check.
*/
pragma[nomagic]
predicate inherits(Class c, Field f) {
f = c.getAField()
or