mirror of
https://github.com/github/codeql.git
synced 2026-05-03 12:45:27 +02:00
Kotlin: Performance tweak
This commit is contained in:
@@ -76,7 +76,7 @@ class CollectionSizeMethod extends CollectionMethod {
|
||||
|
||||
/** A method that mutates the collection it belongs to. */
|
||||
class CollectionMutator extends CollectionMethod {
|
||||
CollectionMutator() { this.getName().regexpMatch("add.*|remove.*|push|pop|clear") }
|
||||
CollectionMutator() { pragma[only_bind_into](this).getName().regexpMatch("add.*|remove.*|push|pop|clear") }
|
||||
}
|
||||
|
||||
/** A method call that mutates a collection. */
|
||||
@@ -89,7 +89,7 @@ class CollectionMutation extends MethodAccess {
|
||||
|
||||
/** A method that queries the contents of a collection without mutating it. */
|
||||
class CollectionQueryMethod extends CollectionMethod {
|
||||
CollectionQueryMethod() { this.getName().regexpMatch("contains|containsAll|get|size|peek") }
|
||||
CollectionQueryMethod() { pragma[only_bind_into](this).getName().regexpMatch("contains|containsAll|get|size|peek") }
|
||||
}
|
||||
|
||||
/** A `new` expression that allocates a fresh, empty collection. */
|
||||
|
||||
@@ -40,7 +40,7 @@ class MapMethod extends Method {
|
||||
|
||||
/** A method that mutates the map it belongs to. */
|
||||
class MapMutator extends MapMethod {
|
||||
MapMutator() { this.getName().regexpMatch("(put.*|remove|clear)") }
|
||||
MapMutator() { pragma[only_bind_into](this).getName().regexpMatch("(put.*|remove|clear)") }
|
||||
}
|
||||
|
||||
/** The `size` method of `java.util.Map`. */
|
||||
@@ -59,7 +59,7 @@ class MapMutation extends MethodAccess {
|
||||
/** A method that queries the contents of the map it belongs to without mutating it. */
|
||||
class MapQueryMethod extends MapMethod {
|
||||
MapQueryMethod() {
|
||||
this.getName().regexpMatch("get|containsKey|containsValue|entrySet|keySet|values|isEmpty|size")
|
||||
pragma[only_bind_into](this).getName().regexpMatch("get|containsKey|containsValue|entrySet|keySet|values|isEmpty|size")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user