From 3fe7bdcedcf38018abf1f4bc189b5297a082700e Mon Sep 17 00:00:00 2001 From: Graham Date: Sat, 23 Jul 2022 10:04:10 +0100 Subject: [PATCH] Optimise CloseableInjector We now avoid provisioning if the binding is not AutoCloseable. --- .../src/main/kotlin/org/openrs2/inject/CloseableInjector.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/inject/src/main/kotlin/org/openrs2/inject/CloseableInjector.kt b/inject/src/main/kotlin/org/openrs2/inject/CloseableInjector.kt index 3bd0fcbb..634881f3 100644 --- a/inject/src/main/kotlin/org/openrs2/inject/CloseableInjector.kt +++ b/inject/src/main/kotlin/org/openrs2/inject/CloseableInjector.kt @@ -12,11 +12,11 @@ public class CloseableInjector( continue } - val o = binding.provider.get() - if (o !is AutoCloseable) { + if (!AutoCloseable::class.java.isAssignableFrom(binding.key.typeLiteral.rawType)) { continue } + val o = binding.provider.get() as AutoCloseable o.close() } }