Skip to content

Commit cb4be0f

Browse files
committed
IsStrictlyWeak: Address performance issue
1 parent 1ee79ac commit cb4be0f

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

cpp/common/src/codingstandards/cpp/rules/orderingpredicatemustbestrictlyweak/OrderingPredicateMustBeStrictlyWeak.qll

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,19 @@ abstract class OrderingPredicateMustBeStrictlyWeakSharedQuery extends Query { }
1414

1515
Query getQuery() { result instanceof OrderingPredicateMustBeStrictlyWeakSharedQuery }
1616

17+
class IsStrictlyWeaklyOrderedComment extends Comment {
18+
IsStrictlyWeaklyOrderedComment() {
19+
getContents().regexpMatch("(?m)^\\s*(//|\\*)\\s*@IsStrictlyWeaklyOrdered\\s*$")
20+
}
21+
}
22+
1723
/**
1824
* User annotated class indicating a comparator is axiomatically strictly weakly
1925
* ordering.
2026
*/
2127
class UserDefinedStrictlyWeakOrderingComparator extends Class {
2228
UserDefinedStrictlyWeakOrderingComparator() {
23-
exists(Comment c, string contents |
24-
c.getCommentedElement() = this.getADeclarationEntry() and
25-
contents =
26-
c.getContents()
27-
.splitAt("\n")
28-
.regexpFind("^\\s*(//|\\*)\\s*@IsStrictlyWeaklyOrdered\\s*$", _, _)
29-
)
29+
exists(IsStrictlyWeaklyOrderedComment c | c.getCommentedElement() = this.getADeclarationEntry())
3030
}
3131
}
3232

0 commit comments

Comments
 (0)