Skip to content

Commit

Permalink
Remove "n" list field setting, decrease OC-LuaJ size.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
asiekierka committed Sep 7, 2022
1 parent e652fd8 commit fa30722
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 7 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
3 changes: 0 additions & 3 deletions src/main/scala/li/cil/oc/util/ExtendedLuaState.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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]) {
Expand Down
4 changes: 1 addition & 3 deletions src/main/scala/li/cil/oc/util/ScalaClosure.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down

0 comments on commit fa30722

Please sign in to comment.