WordPress.org

Make WordPress Core

Opened 3 months ago

Last modified 2 months ago

#43902 new enhancement

Small refactoring to prevent multiple chr() calls in MO class

Reported by: likemusic Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: trunk
Component: I18N Keywords:
Focuses: performance Cc:

Description


Attachments (1)

mo-small-optimize2.diff (3.6 KB) - added by likemusic 3 months ago.
Patch file

Download all attachments as: .zip

Change History (3)

@likemusic
3 months ago

Patch file

#1 @ayeshrajans
3 months ago

Hi @likemusic - welcome to Wordpress Trac! I often go through performance tagged tickets and other PHP-related improvements. I'm just a regular volunteer with no commit privileges, so please take this just as an observation.

Here is a benchmark https://3v4l.org/vkjKg of the suggested change. There doesn't seem to be a noticeable performance difference between two approaches. However, it definitely looks like an improvement in code clarity, following DRY.

I believe there is some work undergoing to revamp this component with a modern approach. I'm sure someone with more understanding will comment soon.

#2 @likemusic
2 months ago

Hi @ayeshrajans !

Thanx for review. According to your test for old version php (before 7.0) using constant decrease time almost for 50%. It's good indicator and imho shoud be merged to develop branch because still many WP sites running on old php versions.

I made this fix because loading translations take most time of request handling after installing some extensions.

I looked for MO loader but can't find any other obvious way to increase translation loading performance.

Seems that it's requires to use some cache to not parse all mo files for every requests (that makes every 30 sec when admin page is opened in browser).

Note: See TracTickets for help on using tickets.