mirror of
https://github.com/github/codeql.git
synced 2026-05-01 11:45:14 +02:00
Merge pull request #6840 from aschackmull/java/misc-perf
Java: Fix some performance issues.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user