Move preg_match() that should only run once out of the loop.
props dllh. fixes #28575. git-svn-id: https://develop.svn.wordpress.org/trunk@28776 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
9642d17ff8
commit
4306de30e3
@ -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 );
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user