From fa30722e6bdbabf58f836b3946fa0968c6d79da8 Mon Sep 17 00:00:00 2001 From: Adrian Siekierka Date: Wed, 7 Sep 2022 17:02:54 +0200 Subject: [PATCH] Remove "n" list field setting, decrease OC-LuaJ size. Setting "n" inside a numbered list was only fully supported up until Lua 5.0, and was fully removed by Lua 5.2 (which is the lowest version we support). To improve performance and memory usage a little, remove setting it across the OpenComputers Lua world (including in our fork of LuaJ). In addition, more unused LuaJ code was removed, saving about ~100-130KB after JAR compression. --- build.gradle | 2 +- src/main/scala/li/cil/oc/util/ExtendedLuaState.scala | 3 --- src/main/scala/li/cil/oc/util/ScalaClosure.scala | 4 +--- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/build.gradle b/build.gradle index 7df0687976..4de7c366b7 100644 --- a/build.gradle +++ b/build.gradle @@ -161,7 +161,7 @@ dependencies { compile 'com.google.code.findbugs:jsr305:1.3.9' // Annotations used by google libs. - embedded name: 'OC-LuaJ', version: '20220904.0', ext: 'jar' + embedded name: 'OC-LuaJ', version: '20220907.1', ext: 'jar' embedded name: 'OC-JNLua', version: '20220904.0', ext: 'jar' embedded name: 'OC-JNLua-Natives', version: '20220904.0', ext: 'jar' diff --git a/src/main/scala/li/cil/oc/util/ExtendedLuaState.scala b/src/main/scala/li/cil/oc/util/ExtendedLuaState.scala index 1d50c56cca..c161371273 100644 --- a/src/main/scala/li/cil/oc/util/ExtendedLuaState.scala +++ b/src/main/scala/li/cil/oc/util/ExtendedLuaState.scala @@ -81,9 +81,6 @@ object ExtendedLuaState { } // Bring table back to top (in case memo values were pushed). lua.pushValue(tableIndex) - lua.pushString("n") - lua.pushInteger(count) - lua.rawSet(-3) } def pushTable(obj: AnyRef, map: Map[_, _], memo: util.IdentityHashMap[Any, Int]) { diff --git a/src/main/scala/li/cil/oc/util/ScalaClosure.scala b/src/main/scala/li/cil/oc/util/ScalaClosure.scala index 801003f7c7..7e6cabe3d7 100644 --- a/src/main/scala/li/cil/oc/util/ScalaClosure.scala +++ b/src/main/scala/li/cil/oc/util/ScalaClosure.scala @@ -59,9 +59,7 @@ object ScalaClosure { } def toLuaList(value: Iterable[Any]): LuaValue = { - val table = LuaValue.listOf(value.map(toLuaValue).toArray) - table.set("n", table.length()) - table + LuaValue.listOf(value.map(toLuaValue).toArray) } def toLuaTable(value: Map[_, _]): LuaValue = {