Speed up is_serialized() with strpbrk(). Props Rasmus. see #14429

git-svn-id: http://svn.automattic.com/wordpress/trunk@15636 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2010-09-20 18:11:06 +00:00
parent 6b351163ef
commit dbe85a7f46
1 changed files with 10 additions and 2 deletions

View File

@ -234,8 +234,16 @@ function is_serialized( $data ) {
$data = trim( $data ); $data = trim( $data );
if ( 'N;' == $data ) if ( 'N;' == $data )
return true; return true;
if ( !preg_match( '/^([adObis]):/', $data, $badions ) ) if ( function_exists('strpbrk') ) {
if ( strlen($data) > 1 && strpbrk($data,'adObis') == $data && $data[1] == ':' ) {
$badions = array();
$badions[1] = $data[0];
} else {
return false; return false;
}
} elseif ( !preg_match( '/^([adObis]):/', $data, $badions ) ) {
return false;
}
switch ( $badions[1] ) { switch ( $badions[1] ) {
case 'a' : case 'a' :
case 'O' : case 'O' :