From 8eb1db919f08f16e06b598c47ea7a4a9f0357ef3 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 22 May 2024 19:02:19 +0700 Subject: [PATCH] Intern strings originating from Lua --- src/main/kotlin/ru/dbotthepony/kstarbound/lua/Conversions.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/lua/Conversions.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/lua/Conversions.kt index aabf0dde..ee3055aa 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/lua/Conversions.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/lua/Conversions.kt @@ -29,6 +29,7 @@ import ru.dbotthepony.kstarbound.math.vector.Vector2i import ru.dbotthepony.kstarbound.json.InternedJsonElementAdapter import ru.dbotthepony.kstarbound.math.AABBi import ru.dbotthepony.kstarbound.math.Line2d +import ru.dbotthepony.kstarbound.util.sbIntern import ru.dbotthepony.kstarbound.world.physics.Poly fun ExecutionContext.toVector2i(table: Any): Vector2i { @@ -122,8 +123,8 @@ fun ExecutionContext.toAABBi(table: Any): AABBi { fun toJsonFromLua(value: Any?): JsonElement { return when (value) { null, is JsonNull -> JsonNull.INSTANCE - is String -> JsonPrimitive(value) - is ByteString -> JsonPrimitive(value.decode()) + is String -> JsonPrimitive(value.sbIntern()) + is ByteString -> JsonPrimitive(value.decode().sbIntern()) is Number -> JsonPrimitive(value) is Boolean -> InternedJsonElementAdapter.of(value) is Table -> value.toJson()