Skip to content

Commit d252a40

Browse files
committed
C++: Speed up Expr.getFullyConverted slightly
This change cuts around 15% of the run time off this predicate. It's a workaround for QL-796.
1 parent 371c09d commit d252a40

File tree

1 file changed

+7
-4
lines changed
  • cpp/ql/src/semmle/code/cpp/exprs

1 file changed

+7
-4
lines changed

cpp/ql/src/semmle/code/cpp/exprs/Expr.qll

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -335,10 +335,10 @@ class Expr extends StmtParent, @expr {
335335
/** Gets the fully converted form of this expression, including all type casts and other conversions. */
336336
cached
337337
Expr getFullyConverted() {
338-
if this.hasConversion() then
339-
result = this.getConversion().getFullyConverted()
340-
else
341-
result = this
338+
hasNoConversions(this) and
339+
result = this
340+
or
341+
result = this.getConversion().getFullyConverted()
342342
}
343343

344344
/**
@@ -977,3 +977,6 @@ private predicate isStandardPlacementNewAllocator(Function operatorNew) {
977977
operatorNew.getNumberOfParameters() = 2 and
978978
operatorNew.getParameter(1).getType() instanceof VoidPointerType
979979
}
980+
981+
// Pulled out for performance. See QL-796.
982+
private predicate hasNoConversions(Expr e) { not e.hasConversion() }

0 commit comments

Comments
 (0)