Skip to content

Commit efe3c0d

Browse files
committed
Kotlin: Performance tweak
1 parent 653e74d commit efe3c0d

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

java/ql/lib/semmle/code/java/Collections.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class CollectionSizeMethod extends CollectionMethod {
7676

7777
/** A method that mutates the collection it belongs to. */
7878
class CollectionMutator extends CollectionMethod {
79-
CollectionMutator() { this.getName().regexpMatch("add.*|remove.*|push|pop|clear") }
79+
CollectionMutator() { pragma[only_bind_into](this).getName().regexpMatch("add.*|remove.*|push|pop|clear") }
8080
}
8181

8282
/** A method call that mutates a collection. */
@@ -89,7 +89,7 @@ class CollectionMutation extends MethodAccess {
8989

9090
/** A method that queries the contents of a collection without mutating it. */
9191
class CollectionQueryMethod extends CollectionMethod {
92-
CollectionQueryMethod() { this.getName().regexpMatch("contains|containsAll|get|size|peek") }
92+
CollectionQueryMethod() { pragma[only_bind_into](this).getName().regexpMatch("contains|containsAll|get|size|peek") }
9393
}
9494

9595
/** A `new` expression that allocates a fresh, empty collection. */

java/ql/lib/semmle/code/java/Maps.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class MapMethod extends Method {
4040

4141
/** A method that mutates the map it belongs to. */
4242
class MapMutator extends MapMethod {
43-
MapMutator() { this.getName().regexpMatch("(put.*|remove|clear)") }
43+
MapMutator() { pragma[only_bind_into](this).getName().regexpMatch("(put.*|remove|clear)") }
4444
}
4545

4646
/** The `size` method of `java.util.Map`. */
@@ -59,7 +59,7 @@ class MapMutation extends MethodAccess {
5959
/** A method that queries the contents of the map it belongs to without mutating it. */
6060
class MapQueryMethod extends MapMethod {
6161
MapQueryMethod() {
62-
this.getName().regexpMatch("get|containsKey|containsValue|entrySet|keySet|values|isEmpty|size")
62+
pragma[only_bind_into](this).getName().regexpMatch("get|containsKey|containsValue|entrySet|keySet|values|isEmpty|size")
6363
}
6464
}
6565

0 commit comments

Comments
 (0)