Skip to content

Commit ab715ec

Browse files
author
Dave Bartolomeo
authored
Merge pull request github#4680 from criemen/printast-performance
C++: Improve PrintAST performance.
2 parents b9b6a35 + a92f7a4 commit ab715ec

File tree

1 file changed

+1
-23
lines changed

1 file changed

+1
-23
lines changed

cpp/ql/src/semmle/code/cpp/Type.qll

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1308,7 +1308,7 @@ class SpecifiedType extends DerivedType {
13081308
* only depends on the specifiers, not on the source program). This is intended
13091309
* for debugging queries only and is an expensive operation.
13101310
*/
1311-
string getSpecifierString() { internalSpecString(this, result, 1) }
1311+
string getSpecifierString() { result = concat(this.getASpecifier().getName(), " ") + " " }
13121312

13131313
override string explain() {
13141314
result = this.getSpecifierString() + "{" + this.getBaseType().explain() + "}"
@@ -1710,28 +1710,6 @@ class AutoType extends TemplateParameter {
17101710
}
17111711
}
17121712

1713-
//
1714-
// Internal implementation predicates
1715-
//
1716-
private predicate allSpecifiers(int i, string s) { s = rank[i](string t | specifiers(_, t) | t) }
1717-
1718-
private predicate internalSpecString(Type t, string res, int i) {
1719-
(
1720-
if allSpecifiers(i, t.getASpecifier().getName())
1721-
then
1722-
exists(string spec, string rest |
1723-
allSpecifiers(i, spec) and
1724-
res = spec + " " + rest and
1725-
internalSpecString(t, rest, i + 1)
1726-
)
1727-
else (
1728-
allSpecifiers(i, _) and internalSpecString(t, res, i + 1)
1729-
)
1730-
)
1731-
or
1732-
i = count(Specifier s) + 1 and res = ""
1733-
}
1734-
17351713
private predicate suppressUnusedThis(Type t) { any() }
17361714

17371715
/** A source code ___location referring to a type */

0 commit comments

Comments
 (0)