From 51dd2713999d65a7d274a4fe34e63a459842c09e Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Fri, 5 Nov 2004 09:13:02 +0000 Subject: [PATCH] Shave off a few more milliseconds from cleanUp() inner loop. --- includes/normal/UtfNormal.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/includes/normal/UtfNormal.php b/includes/normal/UtfNormal.php index eee21883c0..6819b710a8 100644 --- a/includes/normal/UtfNormal.php +++ b/includes/normal/UtfNormal.php @@ -324,10 +324,10 @@ class UtfNormal { # Since PHP is not the fastest language on earth, some of # this code is a little ugly with inner loop optimizations. - $len = strlen( $str ); - $tail = false; + $len = strlen( $str ) + 1; + $tail = 0; $head = ''; - for( $i = 0; $i < $len; $i++ ) { + for( $i = 0; --$len; ++$i ) { if( $tail ) { if( ( $c = $str{$i} ) >= "\x80" && $c < "\xc0" ) { $sequence .= $c; @@ -337,7 +337,7 @@ class UtfNormal { } # We have come to the end of the sequence... - $tail = false; + $tail = 0; if( isset( $checkit[$head] ) ) { # Do some more detailed validity checks, for @@ -383,7 +383,7 @@ class UtfNormal { echo UTF8_REPLACEMENT; } if( $remaining = $tailBytes[$c = $str{$i}] ) { - $tail = true; + $tail = 1; $sequence = $head = $c; } elseif( $c < "\x80" ) { echo $c; -- 2.20.1