WordPress.org

Make WordPress Core

Changeset 24051


Ignore:
Timestamp:
04/22/13 20:01:57 (23 months ago)
Author:
nacin
Message:

Improve the performance of backslashit() by avoiding regular expressions. backslashit() is used heavily in date_i18n().

props jbutkus.
fixes #22286.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/formatting.php

    r23948 r24051  
    13701370 */ 
    13711371function backslashit($string) { 
    1372     $string = preg_replace('/^([0-9])/', '\\\\\\\\\1', $string); 
    1373     $string = preg_replace('/([a-z])/i', '\\\\\1', $string); 
    1374     return $string; 
     1372    if ( isset( $string[0] ) && $string[0] >= '0' && $string[0] <= '9' ) 
     1373        $string = '\\\\' . $string; 
     1374    return addcslashes( $string, 'A..Za..z' ); 
    13751375} 
    13761376 
Note: See TracChangeset for help on using the changeset viewer.