Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize strict.lua #12495

Merged
merged 4 commits into from
Jul 2, 2022
Merged

Optimize strict.lua #12495

merged 4 commits into from
Jul 2, 2022

Conversation

appgurueu
Copy link
Contributor

Just some basic optimizations.

How to test

declared = 1
(function() for _ = 1, 1e3 do undeclared1 = undeclared2 end end)()

Expected: One warning for undeclared1 and one for undeclared2.

core.log("warning", ("Undeclared global variable %q accessed at %s:%s")
:format(name, info.short_src, info.currentline))
warned[warn_key] = true
end
return rawget(self, name)
return nil
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

__index is only called if the value is nil, so there's no need to rawget here

@Zughy Zughy added Maintenance Tasks to keep the codebase and related parts in order, including architectural improvements @ Builtin Code quality labels Jun 30, 2022
builtin/common/strict.lua Outdated Show resolved Hide resolved
builtin/common/strict.lua Outdated Show resolved Hide resolved
@rubenwardy rubenwardy merged commit 3e30858 into minetest:master Jul 2, 2022
@appgurueu appgurueu deleted the patch-8 branch March 31, 2024 18:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@ Builtin Code quality Maintenance Tasks to keep the codebase and related parts in order, including architectural improvements >= Two approvals ✅ ✅
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants