Kotlin: Performance tweak

This commit is contained in:
Ian Lynagh
2022-04-26 15:11:09 +01:00
parent 653e74d181
commit efe3c0d1ea
2 changed files with 4 additions and 4 deletions

View File

@@ -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. */

View File

@@ -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")
}
}