mirror of
git://develop.git.wordpress.org/
synced 2025-01-17 12:58:25 +01:00
Emoji: Improve performance when encoding or staticizing emoji.
Both `wp_encode_emoji()` and `wp_staticize_emoji()` perform a PHP version check when deciding how to apply their behaviour, but this check only needs to happen once, rather than every time in their internal looks. Moving the check outside of the loop reduces processing time by 50%. Props johnbillion. Fixes #45930. git-svn-id: https://develop.svn.wordpress.org/trunk@44554 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
041471735a
commit
d32cead515
@ -5477,9 +5477,10 @@ function _print_emoji_detection_script() {
|
||||
*/
|
||||
function wp_encode_emoji( $content ) {
|
||||
$emoji = _wp_emoji_list( 'partials' );
|
||||
$compat = version_compare( phpversion(), '5.4', '<' );
|
||||
|
||||
foreach ( $emoji as $emojum ) {
|
||||
if ( version_compare( phpversion(), '5.4', '<' ) ) {
|
||||
if ( $compat ) {
|
||||
$emoji_char = html_entity_decode( $emojum, ENT_COMPAT, 'UTF-8' );
|
||||
} else {
|
||||
$emoji_char = html_entity_decode( $emojum );
|
||||
@ -5519,9 +5520,10 @@ function wp_staticize_emoji( $text ) {
|
||||
|
||||
// Quickly narrow down the list of emoji that might be in the text and need replacing.
|
||||
$possible_emoji = array();
|
||||
$compat = version_compare( phpversion(), '5.4', '<' );
|
||||
foreach ( $emoji as $emojum ) {
|
||||
if ( false !== strpos( $text, $emojum ) ) {
|
||||
if ( version_compare( phpversion(), '5.4', '<' ) ) {
|
||||
if ( $compat ) {
|
||||
$possible_emoji[ $emojum ] = html_entity_decode( $emojum, ENT_COMPAT, 'UTF-8' );
|
||||
} else {
|
||||
$possible_emoji[ $emojum ] = html_entity_decode( $emojum );
|
||||
|
Loading…
x
Reference in New Issue
Block a user