[wp-trac] [WordPress Trac] #58317: Refactor determine_locale() for performance
WordPress Trac
noreply at wordpress.org
Wed Jun 7 10:43:04 UTC 2023
#58317: Refactor determine_locale() for performance
--------------------------------------+--------------------------
Reporter: Cybr | Owner: swissspidy
Type: enhancement | Status: reopened
Priority: normal | Milestone: 6.3
Component: I18N | Version: trunk
Severity: normal | Resolution:
Keywords: has-patch has-unit-tests | Focuses: performance
--------------------------------------+--------------------------
Comment (by swissspidy):
Thanks for letting me know! I'll take a closer look soon, so here's just a
quick reply to your points in the meantime.
1. Both are pretty simple functions, so I don't think it makes a big
difference in this case.
2. WordPress actually does have a standard
([https://developer.wordpress.org/coding-standards/wordpress-coding-
standards/php/#use-elseif-not-else-if `elseif`]), and I mixed it up. Good
catch!
3. I see your point, but I'm not introducing the short ternary operator
here because it's against the coding standards.
4. A consequence of not using short ternary operators, no? Let me know if
you have a specific change in mind.
5. So your patch inadvertently fixed an edge case bug that was already
present in core before this change, right? Because with the added tests I
ensured that the existing behavior didn't change. Happy to fix some edge
cases with accompanying tests.
All in all it seems like the committed changes have improved the function
quite a bit, while keeping it readable at the same time. Given that the
function is not called super often, what is the impact of your proposed
changes on an actual WP page load?
--
Ticket URL: <https://core.trac.wordpress.org/ticket/58317#comment:17>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list