[wp-trac] [WordPress Trac] #56784: Optimization in wp_staticize_emoji function
WordPress Trac
noreply at wordpress.org
Fri Jan 10 07:32:07 UTC 2025
#56784: Optimization in wp_staticize_emoji function
--------------------------+------------------------------
Reporter: kac1per | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Emoji | Version: 6.0.2
Severity: normal | Resolution:
Keywords: needs-patch | Focuses: performance
--------------------------+------------------------------
Comment (by zwqdpkb086):
The current wp_staticize_emoji function attempts to optimize by using
strpos() to pre-check if emojis exist in the text. However, this creates
significant overhead because it iterates through all 3575 emoji entities,
performing a costly operation for each one.
**Issue:** Pre-checking with strpos() is slower than processing all emojis
directly, as it unnecessarily adds computational complexity.
**Solution:** Skip the strpos() checks and process all emojis at once.
This approach consistently improves performance (up to 10x faster) by
eliminating redundant operations.
**Recommendation:** Simplify the function by directly handling all emoji
entities without pre-checks, which results in faster execution without
affecting functionality.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/56784#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list