-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
no global var #19282
no global var #19282
Conversation
What's wrong with the global variable? |
It's only used inside the function - it should never be global!!! |
You see, it's not a simple global variable. It's a cache. It's usually It helps the I do not see the necessary to change it. If you want to change it, the logic inside |
I dont think we need to cache this as install page will only show up on installation |
Then you should also remove the |
in general we should avoid global vars if possible they produce races, consume resources not needed after exec of code parts mostly ... |
As comments before, it's just a install page, no race there. And it only consumes 8 bytes (a pointer) memory. Just one request consume much much more than that .... Personally I won't put too many loops in the common Context construction. Indeed there is no problem to remove the cache if you like to. |
There still may be a performance benefit of keeping these top-level variables in case their instantiation is expensive. For example, I like to put regexes in top level because pre-compiling them will always be better performance than to compile them on every function call. |
|
For the |
last missing nit from #17919