From d46e7dbfc037a0fe3fc87041863b80b139ef04ac Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Mon, 20 Sep 2010 18:11:06 +0000 Subject: [PATCH] Speed up is_serialized() with strpbrk(). Props Rasmus. see #14429 git-svn-id: https://develop.svn.wordpress.org/trunk@15636 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/functions.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 7c566729c0..3b4e4012e2 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -232,10 +232,18 @@ function is_serialized( $data ) { if ( !is_string( $data ) ) return false; $data = trim( $data ); - if ( 'N;' == $data ) + if ( 'N;' == $data ) 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; + } + } elseif ( !preg_match( '/^([adObis]):/', $data, $badions ) ) { return false; + } switch ( $badions[1] ) { case 'a' : case 'O' :