Intern strings originating from Lua
This commit is contained in:
parent
e81079479b
commit
8eb1db919f
@ -29,6 +29,7 @@ import ru.dbotthepony.kstarbound.math.vector.Vector2i
|
|||||||
import ru.dbotthepony.kstarbound.json.InternedJsonElementAdapter
|
import ru.dbotthepony.kstarbound.json.InternedJsonElementAdapter
|
||||||
import ru.dbotthepony.kstarbound.math.AABBi
|
import ru.dbotthepony.kstarbound.math.AABBi
|
||||||
import ru.dbotthepony.kstarbound.math.Line2d
|
import ru.dbotthepony.kstarbound.math.Line2d
|
||||||
|
import ru.dbotthepony.kstarbound.util.sbIntern
|
||||||
import ru.dbotthepony.kstarbound.world.physics.Poly
|
import ru.dbotthepony.kstarbound.world.physics.Poly
|
||||||
|
|
||||||
fun ExecutionContext.toVector2i(table: Any): Vector2i {
|
fun ExecutionContext.toVector2i(table: Any): Vector2i {
|
||||||
@ -122,8 +123,8 @@ fun ExecutionContext.toAABBi(table: Any): AABBi {
|
|||||||
fun toJsonFromLua(value: Any?): JsonElement {
|
fun toJsonFromLua(value: Any?): JsonElement {
|
||||||
return when (value) {
|
return when (value) {
|
||||||
null, is JsonNull -> JsonNull.INSTANCE
|
null, is JsonNull -> JsonNull.INSTANCE
|
||||||
is String -> JsonPrimitive(value)
|
is String -> JsonPrimitive(value.sbIntern())
|
||||||
is ByteString -> JsonPrimitive(value.decode())
|
is ByteString -> JsonPrimitive(value.decode().sbIntern())
|
||||||
is Number -> JsonPrimitive(value)
|
is Number -> JsonPrimitive(value)
|
||||||
is Boolean -> InternedJsonElementAdapter.of(value)
|
is Boolean -> InternedJsonElementAdapter.of(value)
|
||||||
is Table -> value.toJson()
|
is Table -> value.toJson()
|
||||||
|
Loading…
Reference in New Issue
Block a user