Optimization

This page documents the optimization command.

LD can optimize Lua files by using the /optimize command in the DMs of the bot.

Once you have used the command, select the options you would like. Then, upload a file to the bot and press the Optimize button and wait for the bot to respond.

Optimization Options

Fold Constants

This option will fold constant expressions (0 + 1 will be turned into 1).

Inline Constants

Constant variables will be inlined.

local variable = 1
print(variable)

With Inline Constants enabled, this code will be optimized to the following:

print(1)

Inline Globals

Known globals and standard library functions will be inlined.

local math_floor = math.floor
local get_environment = getfenv

get_environment().value = math_floor(global)

With Inline Globals enabled, this code will be optimized to the following:

getfenv().value = math.floor(global)

Last updated