From 7e6f32c47b0f4cdb2f5fb9ccad614427df6c4c03 Mon Sep 17 00:00:00 2001 From: Andreas Gohr <andi@splitbrain.org> Date: Sun, 26 Jul 2009 21:18:41 +0200 Subject: [PATCH] rollback of the rollback... yes really Ignore-this: 77a6ae8bee651ddb193e0ed84cbe3667 Okay, so it turned out Chris' test had a bug and wasn't really testing and my test was skewed by disk caching (remember: always run your performance tests multiple times). rolling back: Sat Jul 25 12:44:59 CEST 2009 Andreas Gohr <andi@splitbrain.org> * rollback of the utf8_isASCII() patch Tests showed the old code was faster and I was too stupid to read the test results rolling back: Fri Jul 24 10:40:09 CEST 2009 Andreas Haerter <netzmeister@andreas-haerter.de> * Much faster version of utf8_isASCII() This version uses a non-capturing regular expression instead of looping through all characters of the string. M ./inc/utf8.php -5 +2 M ./inc/utf8.php -2 +5 darcs-hash:20090726191841-7ad00-13950d9c528abd51f5680c6841ec738a0ee72130.gz --- inc/utf8.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/inc/utf8.php b/inc/utf8.php index e2f016942..85e5f4f7e 100644 --- a/inc/utf8.php +++ b/inc/utf8.php @@ -62,13 +62,10 @@ if(!function_exists('utf8_isASCII')){ /** * Checks if a string contains 7bit ASCII only * - * @author Andreas Gohr <andi@splitbrain.org> + * @author Andreas Haerter <netzmeister@andreas-haerter.de> */ function utf8_isASCII($str){ - for($i=0; $i<strlen($str); $i++){ - if(ord($str{$i}) >127) return false; - } - return true; + return (preg_match('/(?:[^\x00-\x7F])/', $str) !== 1); } } -- GitLab