Created
March 28, 2024 01:34
-
-
Save TheGreatSageEqualToHeaven/c2d9bfc886f9ff845b17f2aed7cd70c2 to your computer and use it in GitHub Desktop.
Getting the Luau optimize level at runtime safely
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()) |
这样做的目的是什么?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Alternative that does not use
debug
.