#45930 closed enhancement (fixed)
Improve the performance of emoji iteration in `wp_encode_emoji()` and `wp_staticize_emoji()`
Reported by: | johnbillion | Owned by: | pento |
---|---|---|---|
Milestone: | 5.1 | Priority: | normal |
Severity: | normal | Version: | 4.9 |
Component: | Emoji | Keywords: | has-patch commit |
Focuses: | performance | Cc: |
Description
The wp_encode_emoji()
and wp_staticize_emoji()
functions perform a version comparison against the PHP version for every emoji that they iterate over - currently either 1,250 or 2,839 depending on whether the partial or full list of emoji are being iterated.
This behaviour was introduced in [41702].
By moving the PHP version comparison out of the loop, those thousands of comparisons are avoided and the processing time of both functions are reduced by approximately 50%.
1,000 iterations of wp_encode_emoji()
before the proposed change: 4.0 seconds.
1,000 iterations of wp_encode_emoji()
after the proposed change: 1.9 seconds.
Attachments (1)
Change History (6)
Note: See
TracTickets for help on using
tickets.
Noice. 🙂
If WordPress 5.2 is going to drop PHP<5.6 support, not much point waiting until then, so let's do this in 5.1.