From bf664ea0c56a03a66091039c082277c16eb0839b Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Tue, 28 Oct 2025 12:18:19 -0400 Subject: [PATCH] Avoids interning of large strings and objects where the duplication is not common --- .../com/vitorpamplona/quartz/benchmark/ContainsBenchmark.kt | 2 +- .../intents/results/IntentResultJsonDeserializer.kt | 4 ++-- .../nip46RemoteSigner/jackson/BunkerRequestDeserializer.kt | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/benchmark/src/androidTest/java/com/vitorpamplona/quartz/benchmark/ContainsBenchmark.kt b/benchmark/src/androidTest/java/com/vitorpamplona/quartz/benchmark/ContainsBenchmark.kt index 2ca0f06bc..cc6c0a079 100644 --- a/benchmark/src/androidTest/java/com/vitorpamplona/quartz/benchmark/ContainsBenchmark.kt +++ b/benchmark/src/androidTest/java/com/vitorpamplona/quartz/benchmark/ContainsBenchmark.kt @@ -38,7 +38,7 @@ class ContainsBenchmark { """Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32. The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham. -""".intern() +""" val atTheMiddle = DualCase("Lorem Ipsum".lowercase(), "Lorem Ipsum".uppercase()) val atTheBeginning = DualCase("contrAry".lowercase(), "contrAry".uppercase()) diff --git a/quartz/src/androidMain/kotlin/com/vitorpamplona/quartz/nip55AndroidSigner/api/foreground/intents/results/IntentResultJsonDeserializer.kt b/quartz/src/androidMain/kotlin/com/vitorpamplona/quartz/nip55AndroidSigner/api/foreground/intents/results/IntentResultJsonDeserializer.kt index 7b21edf39..0631da0d9 100644 --- a/quartz/src/androidMain/kotlin/com/vitorpamplona/quartz/nip55AndroidSigner/api/foreground/intents/results/IntentResultJsonDeserializer.kt +++ b/quartz/src/androidMain/kotlin/com/vitorpamplona/quartz/nip55AndroidSigner/api/foreground/intents/results/IntentResultJsonDeserializer.kt @@ -33,8 +33,8 @@ class IntentResultJsonDeserializer : StdDeserializer(IntentResult: val jsonObject: JsonNode = jp.codec.readTree(jp) return IntentResult( `package` = jsonObject.get("package")?.asText()?.intern(), - result = jsonObject.get("result")?.asText()?.intern(), - event = jsonObject.get("event")?.asText()?.intern(), + result = jsonObject.get("result")?.asText(), + event = jsonObject.get("event")?.asText(), id = jsonObject.get("id")?.asText()?.intern(), rejected = jsonObject.get("rejected")?.asBoolean() ?: false, ) diff --git a/quartz/src/jvmAndroid/kotlin/com/vitorpamplona/quartz/nip46RemoteSigner/jackson/BunkerRequestDeserializer.kt b/quartz/src/jvmAndroid/kotlin/com/vitorpamplona/quartz/nip46RemoteSigner/jackson/BunkerRequestDeserializer.kt index 701a67ef2..ee7cb6786 100644 --- a/quartz/src/jvmAndroid/kotlin/com/vitorpamplona/quartz/nip46RemoteSigner/jackson/BunkerRequestDeserializer.kt +++ b/quartz/src/jvmAndroid/kotlin/com/vitorpamplona/quartz/nip46RemoteSigner/jackson/BunkerRequestDeserializer.kt @@ -42,9 +42,9 @@ class BunkerRequestDeserializer : StdDeserializer(BunkerRequest:: ctxt: DeserializationContext, ): BunkerRequest { val jsonObject: JsonNode = jp.codec.readTree(jp) - val id = jsonObject.get("id").asText().intern() - val method = jsonObject.get("method").asText().intern() - val params = jsonObject.get("params")?.toTypedArray { it.asText().intern() } ?: emptyArray() + val id = jsonObject.get("id").asText() + val method = jsonObject.get("method").asText() + val params = jsonObject.get("params")?.toTypedArray { it.asText() } ?: emptyArray() return when (method) { BunkerRequestConnect.METHOD_NAME -> BunkerRequestConnect.parse(id, params)