Skip to content

Instantly share code, notes, and snippets.

@TheGreatSageEqualToHeaven
Created March 28, 2024 01:34
Show Gist options
  • Save TheGreatSageEqualToHeaven/c2d9bfc886f9ff845b17f2aed7cd70c2 to your computer and use it in GitHub Desktop.
Save TheGreatSageEqualToHeaven/c2d9bfc886f9ff845b17f2aed7cd70c2 to your computer and use it in GitHub Desktop.
Getting the Luau optimize level at runtime safely
local function getOptimizeLevel()
local function dupclosure()
return function() end
end
local O0 = dupclosure() ~= dupclosure()
local function inlinefunction()
return debug.info(1, "f")
end
local f = debug.info(1, "f")
local O2 = f == inlinefunction()
return if O0 then "O0" else (O2 and "O2" or "O1")
end;
print(getOptimizeLevel())
@bluepilledgreat
Copy link

这样做的目的是什么?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment