ZF-227: regex pattern in Zend_Json_Decode::_eatWhitespace() method

Description

It is written using following regular expression code. '/(\t|\b|\f|\n|\r| )/s' But I think it's better to change like this, if it means the same. '/[\t\b\f\n\r ]/s'

# regular expression using pipe is too slow

// Sample benchmark code $text = 'abc a b c abcde fghij'; $pattern1 = '/(\t|\b|\f|\n|\r| )/s'; $pattern2 = '/[\t\b\f\n\r ]/s'; $time = microtime(true); for ($i = 0; $i < 100000; $i ++) { preg_match($pattern1, $text); } echo $pattern1 .': ' . (microtime(true) - $time) . "\n";

$time = microtime(true); for ($i = 0; $i < 100; $i ++) { preg_match($pattern2, $text); }

echo $pattern2 .': ' . (microtime(true) - $time) . "\n";

Result: /(\t|\b|\f|\n|\r| )/s: 3.1665399074554 /[\t\b\f\n\r ]/s: 0.0034799575805664

Comments

Fixed in commit 926