From ce0d1a026c3df672ce4c1eaeb647bca38b7ebefc Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Thu, 19 Jun 2014 00:01:16 +0000 Subject: [PATCH] Move preg_match() that should only run once out of the loop. props dllh. fixes #28575. Built from https://develop.svn.wordpress.org/trunk@28776 git-svn-id: http://core.svn.wordpress.org/trunk@28589 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/formatting.php | 4 +++- wp-includes/version.php | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/wp-includes/formatting.php b/wp-includes/formatting.php index 5006bb183b..9a623896c8 100644 --- a/wp-includes/formatting.php +++ b/wp-includes/formatting.php @@ -214,6 +214,8 @@ function wptexturize($text, $reset = false) { $textarr = preg_split( $regex, $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY ); + $do_times_check = ( 1 === preg_match( '/(?<=\d)x-?\d/', $text ) ); + foreach ( $textarr as &$curl ) { // Only call _wptexturize_pushpop_element if $curl is a delimeter. $first = $curl[0]; @@ -242,7 +244,7 @@ function wptexturize($text, $reset = false) { $curl = preg_replace($dynamic_characters, $dynamic_replacements, $curl); // 9x9 (times), but never 0x9999 - if ( 1 === preg_match( '/(?<=\d)x-?\d/', $text ) ) { + if ( $do_times_check ) { // Searching for a digit is 10 times more expensive than for the x, so we avoid doing this one! $curl = preg_replace( '/\b(\d(?(?<=0)[\d\.,]+|[\d\.,]*))x(-?\d[\d\.,]*)\b/', '$1×$2', $curl ); } diff --git a/wp-includes/version.php b/wp-includes/version.php index eaa27e8094..0f5752ff59 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.0-alpha-20140618'; +$wp_version = '4.0-alpha-20140619'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.