summaryrefslogtreecommitdiff
path: root/inc
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2009-07-26 21:18:41 +0200
committerAndreas Gohr <andi@splitbrain.org>2009-07-26 21:18:41 +0200
commit7e6f32c47b0f4cdb2f5fb9ccad614427df6c4c03 (patch)
tree189991b0aa88cf6d2207fb8bb44d68d10e1c1d21 /inc
parent8cd177c06d84c228e8bbaf04d94cfbd1f468684a (diff)
downloadrpg-7e6f32c47b0f4cdb2f5fb9ccad614427df6c4c03.tar.gz
rpg-7e6f32c47b0f4cdb2f5fb9ccad614427df6c4c03.tar.bz2
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
Diffstat (limited to 'inc')
-rw-r--r--inc/utf8.php7
1 files 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);
}
}