[wp-trac] [WordPress Trac] #35293: Emoji Regex in wp_encode_emoji() is wildly inaccurate

WordPress Trac noreply at wordpress.org
Thu Aug 3 00:08:39 UTC 2017


#35293: Emoji Regex in wp_encode_emoji() is wildly inaccurate
--------------------------+-----------------------
 Reporter:  pento         |       Owner:  pento
     Type:  defect (bug)  |      Status:  reopened
 Priority:  normal        |   Milestone:  4.9
Component:  Emoji         |     Version:  4.2
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:
--------------------------+-----------------------

Comment (by pento):

 == Test 6

 The slowest part of the code seems to be encoding, so reducing the number
 of characters to replace would be prudent. This test breaks the emoji down
 into their individual characters, and encodes each one separately. This
 reduces the number of items to encode from 2661 to 1186, but probably
 increases the number of `str_replace()` calls each loop has to do.

 '''Data''': https://travis-ci.org/pento/test-41501/builds/260416806

 '''Analysis''':
 - Performance changes seem to be fairly consistent across all PHP
 versions.
 - Moderate improvements for short-medium posts with 0% or 1% emoji.
 - Severe performance penalties for very long posts with lots of emoji. For
 example, PHP 7, en_US, 10% emoji, super long post increased from 2700ms to
 3400ms (though is still faster than the old code, which took 3700ms).

 '''Conclusion''': Likely good to include, the performance penalties are
 for fairly severe edge cases, which haven't bitten us prior to the work on
 this ticket.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/35293#comment:34>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list