From e6eaf6cb73cdc38c5a760ed4230d3cf71e908d45 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Fri, 28 Nov 2025 14:25:35 +0100 Subject: [PATCH] feat: Infer cache key from unique instance hashcode --- src/main/kotlin/app/revanced/patcher/Matching.kt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/app/revanced/patcher/Matching.kt b/src/main/kotlin/app/revanced/patcher/Matching.kt index 6b862ae..5c94cbf 100644 --- a/src/main/kotlin/app/revanced/patcher/Matching.kt +++ b/src/main/kotlin/app/revanced/patcher/Matching.kt @@ -225,12 +225,16 @@ fun Iterable.matchIndexed(build: IndexedMatcher.() -> Unit) = indexedMatcher(build)(this) context(_: MatchContext) -operator fun IndexedMatcher.invoke(iterable: Iterable, key: String, builder: IndexedMatcher.() -> Unit) = +fun Iterable.matchIndexed(key: Any, build: IndexedMatcher.() -> Unit) = + indexedMatcher()(key, this, build) + +context(_: MatchContext) +operator fun IndexedMatcher.invoke(key: Any, iterable: Iterable, builder: IndexedMatcher.() -> Unit) = remember(key) { apply(builder) }(iterable) context(_: MatchContext) -fun Iterable.matchIndexed(key: String, build: IndexedMatcher.() -> Unit) = - indexedMatcher()(this, key, build) +operator fun IndexedMatcher.invoke(iterable: Iterable, builder: IndexedMatcher.() -> Unit) = + invoke(hashCode(), iterable, builder) abstract class Matcher : MutableList by mutableListOf() { var matchIndex = -1