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.
This commit is contained in:
Adrian Siekierka 2022-09-07 17:02:54 +02:00
parent e652fd8df1
commit fa30722e6b
3 changed files with 2 additions and 7 deletions

View File

@ -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'

View File

@ -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]) {

View File

@ -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 = {