mirror of
https://github.com/WordPress/WordPress.git
synced 2025-01-03 15:08:10 +01:00
Improve the performance of backslashit() by avoiding regular expressions. backslashit() is used heavily in date_i18n().
props jbutkus. fixes #22286. git-svn-id: http://core.svn.wordpress.org/trunk@24051 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
1f64b5abd0
commit
f1aeebf00b
@ -1369,9 +1369,9 @@ function zeroise($number, $threshold) {
|
|||||||
* @return string String with backslashes inserted.
|
* @return string String with backslashes inserted.
|
||||||
*/
|
*/
|
||||||
function backslashit($string) {
|
function backslashit($string) {
|
||||||
$string = preg_replace('/^([0-9])/', '\\\\\\\\\1', $string);
|
if ( isset( $string[0] ) && $string[0] >= '0' && $string[0] <= '9' )
|
||||||
$string = preg_replace('/([a-z])/i', '\\\\\1', $string);
|
$string = '\\\\' . $string;
|
||||||
return $string;
|
return addcslashes( $string, 'A..Za..z' );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user