Skip to content

Commit dfdfe9b

Browse files
committed
NotDistinctIdentifier: Performance optimization
Hint optimizer to perform join of exclusions after determining results.
1 parent 7eaad20 commit dfdfe9b

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

cpp/common/src/codingstandards/cpp/rules/notdistinctidentifier/NotDistinctIdentifier.qll

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,16 @@ abstract class NotDistinctIdentifierSharedQuery extends Query { }
1212

1313
Query getQuery() { result instanceof NotDistinctIdentifierSharedQuery }
1414

15+
bindingset[d, d2]
16+
pragma[inline_late]
17+
private predicate after(ExternalIdentifiers d, ExternalIdentifiers d2) {
18+
exists(int dStartLine, int d2StartLine |
19+
d.getLocation().hasLocationInfo(_, dStartLine, _, _, _) and
20+
d2.getLocation().hasLocationInfo(_, d2StartLine, _, _, _) and
21+
dStartLine >= d2StartLine
22+
)
23+
}
24+
1525
query predicate problems(
1626
ExternalIdentifiers d, string message, ExternalIdentifiers d2, string nameplaceholder
1727
) {
@@ -20,10 +30,10 @@ query predicate problems(
2030
d.getName().length() >= 31 and
2131
d2.getName().length() >= 31 and
2232
not d = d2 and
23-
d.getLocation().getStartLine() >= d2.getLocation().getStartLine() and
2433
d.getSignificantName() = d2.getSignificantName() and
2534
not d.getName() = d2.getName() and
2635
nameplaceholder = d2.getName() and
36+
after(d, d2) and
2737
message =
2838
"External identifer " + d.getName() +
2939
" is nondistinct in characters at or over 31 limit, compared to $@"

0 commit comments

Comments
 (0)