Java: Fix some performance issues. · github/codeql@2185a65 · GitHub
Skip to content

Commit 2185a65

Browse files
committed
Java: Fix some performance issues.
1 parent 951df38 commit 2185a65

3 files changed

Lines changed: 10 additions & 5 deletions

File tree

‎java/ql/src/Likely Bugs/Collections/IteratorRemoveMayFail.ql‎

Lines changed: 2 additions & 2 deletions

‎java/ql/src/Likely Bugs/Comparison/StringComparison.ql‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,21 @@ class StringValue extends Expr {
4141
}
4242
}
4343

44-
predicate variableValuesInterned(Variable v) {
44+
predicate candidateVariable(Variable v) {
4545
v.fromSource() and
46-
// All assignments to variables are interned.
47-
forall(StringValue sv | sv = v.getAnAssignedValue() | sv.isInterned()) and
4846
// For parameters, assume they could be non-interned.
4947
not v instanceof Parameter and
5048
// If the string is modified with `+=`, then the new string is not interned
5149
// even if the components are.
5250
not exists(AssignOp append | append.getDest() = v.getAnAccess())
5351
}
5452

53+
predicate variableValuesInterned(Variable v) {
54+
candidateVariable(v) and
55+
// All assignments to variables are interned.
56+
forall(StringValue sv | sv = v.getAnAssignedValue() | sv.isInterned())
57+
}
58+
5559
from EqualityTest e, StringValue lhs, StringValue rhs
5660
where
5761
e.getLeftOperand() = lhs and

‎java/ql/src/Performance/InnerClassCouldBeStatic.ql‎

Lines changed: 1 addition & 0 deletions

0 commit comments

Comments
 (0)