[wp-trac] [WordPress Trac] #26638: Performance Increase in l10n (9-12%)
WordPress Trac
noreply at wordpress.org
Thu Jul 7 19:01:15 UTC 2022
#26638: Performance Increase in l10n (9-12%)
-------------------------+--------------------------
Reporter: dshafik | Owner: (none)
Type: enhancement | Status: closed
Priority: normal | Milestone:
Component: I18N | Version: 2.9
Severity: normal | Resolution: wontfix
Keywords: has-patch | Focuses: performance
-------------------------+--------------------------
Changes (by SergeyBiryukov):
* keywords: has-patch needs-testing reporter-feedback dev-feedback => has-
patch
Comment:
Found this ticket again while looking at #26640.
It looks like the `NOOP_Translations` usage was improved in [36538] /
#21319, where we save an instance of the class to a static variable
instead of creating a new instance every time, as originally implemented
in [12080] / #10971.
Out of curiosity, I've experimented a bit more with something along the
lines of:
{{{
if ( isset( $l10n[ $domain ] ) ) {
$translations = $l10n[ $domain ];
} else {
$translations = get_translations_for_domain( $domain );
}
if ( $translations instanceof Translations ) {
$translation = $translations->translate( $text );
} else {
$translation = $text;
}
}}}
But that did not provide any noticeable performance improvement, at least
not on PHP 8.0.x. So I guess these particular micro-optimizations are no
longer relevant here.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/26638#comment:21>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list