Skip to content

Commit 9a1d770

Browse files
authored
Merge pull request #858 from github/lcartey/2.19.4-perf-improvements
2.19.4 upgrade performance improvements
2 parents 6bcfc49 + 98944ee commit 9a1d770

File tree

3 files changed

+28
-24
lines changed

3 files changed

+28
-24
lines changed

cpp/autosar/src/codingstandards/cpp/HardwareOrProtocolInterface.qll

+8-6
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@ import codingstandards.cpp.CommonTypes as CommonTypes
33

44
abstract class HardwareOrProtocolInterfaceClass extends Class { }
55

6+
class HardwareOrProtocolInterfaceComment extends Comment {
7+
HardwareOrProtocolInterfaceComment() {
8+
exists(getContents().regexpFind("(?m)^\\s*(//|\\*)\\s*@HardwareOrProtocolInterface\\s*$", _, _))
9+
}
10+
}
11+
612
class AnnotatedHardwareOrProtocolInterfaceClass extends HardwareOrProtocolInterfaceClass {
713
AnnotatedHardwareOrProtocolInterfaceClass() {
8-
exists(Comment c, string contents |
9-
c.getCommentedElement() = this.getADeclarationEntry() and
10-
contents =
11-
c.getContents()
12-
.splitAt("\n")
13-
.regexpFind("^\\s*(//|\\*)\\s*@HardwareOrProtocolInterface\\s*$", _, _)
14+
exists(HardwareOrProtocolInterfaceComment c |
15+
c.getCommentedElement() = this.getADeclarationEntry()
1416
)
1517
}
1618
}

cpp/autosar/src/rules/A2-3-1/InvalidCharacterInComment.ql

+13-11
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,23 @@
1818
import cpp
1919
import codingstandards.cpp.autosar
2020

21-
bindingset[s]
22-
string getCharOutsideBasicSourceCharSet(string s) {
23-
result = s.regexpFind("[\\u0000-\\u007f]", _, _) and
24-
not result.regexpMatch("[\\p{Alnum}\\p{Space}_{}\\[\\]#()<>%:;.?*+-/^&|~!=,\\\\\"'@]")
25-
or
26-
result = s.regexpFind("[\\u00c0-\\u00df][\\u0080-\\u00bf]", _, _)
27-
or
28-
result = s.regexpFind("[\\u00e0-\\u00ef][\\u0080-\\u00bf]{2}", _, _)
29-
or
30-
result = s.regexpFind("[\\u00f0-\\u00f7][\\u0080-\\u00bf]{3}", _, _)
21+
string getCharOutsideBasicSourceCharSet(Comment c) {
22+
exists(string s | s = c.getContents() |
23+
result =
24+
s.regexpFind("(?![\\p{Alnum}\\p{Space}_{}\\[\\]#()<>%:;.?*+-/^&|~!=,\\\\\"'@])[\\u0000-\\u007f]",
25+
_, _)
26+
or
27+
result = s.regexpFind("[\\u00c0-\\u00df][\\u0080-\\u00bf]", _, _)
28+
or
29+
result = s.regexpFind("[\\u00e0-\\u00ef][\\u0080-\\u00bf]{2}", _, _)
30+
or
31+
result = s.regexpFind("[\\u00f0-\\u00f7][\\u0080-\\u00bf]{3}", _, _)
32+
)
3133
}
3234

3335
from Comment c, string ch
3436
where
3537
not isExcluded(c, NamingPackage::invalidCharacterInCommentQuery()) and
36-
ch = getCharOutsideBasicSourceCharSet(c.getContents())
38+
ch = getCharOutsideBasicSourceCharSet(c)
3739
select c,
3840
"Comment uses the character '" + ch + "' that is outside the language basic character set."

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

+7-7
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+
exists(getContents().regexpFind("(?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)