-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
refactor(core): add an empty table in constants then we can reuse it #11443
Conversation
Is the local x = (d or EMPTY).x or "default"
local x = (d and d.doge or EMPTY).x or "default" Which you also see in forms of: local x = (d or {}).x or "default"
local x = (d and d.doge or {}).x or "default" I am not huge fan of either, but some prefer it. The constant seems to be just to avoid table creation (but I am not sure if in those above examples LuaJIT would optimize it away anyway, and even if not, is it a big deal). The later example has benefit of not requiring a module to get If I were to pick, I would just change code everywhere to just |
I don't see the benefit of an |
We already defined many |
I guess the suggestion was to remove all |
Let's keep the code base no changing until we get a agreement. |
Summary
The read-only empty table is very useful, it is widely used in kong's code base,
but its definition scatters in many different files.
This PR defines one and only empty table in
constants.lua
, other lua modules can use it easily.I just changed
EMPTY
in some but not all modules,if most of us think it is good, we will try to change all of them.
Checklist
Full changelog
Issue reference
Fix #[issue number]