partially replace the loop with a duff device
authorMichael Wallner <mike@php.net>
Fri, 13 Feb 2015 10:21:06 +0000 (11:21 +0100)
committerMichael Wallner <mike@php.net>
Fri, 13 Feb 2015 10:21:06 +0000 (11:21 +0100)
php_http_utf8.h

index c7bcb49428c53a79234593390c3705d9ca791af5..d67910fb82aff5453541f01fe0b8d30e4a8e1db1 100644 (file)
@@ -595,9 +595,9 @@ static inline size_t utf8towc(unsigned *wc, const unsigned char *uc, size_t len)
 
 static inline zend_bool isualpha(unsigned ch)
 {
-       unsigned i, j;
+       unsigned i = 0, j;
 
-       for (i = 0; i < sizeof(utf8_ranges)/sizeof(utf8_range_t); ++i) {
+       PHP_HTTP_DUFF(sizeof(utf8_ranges)/sizeof(utf8_range_t),
                if (utf8_ranges[i].start == ch) {
                        return 1;
                } else if (utf8_ranges[i].start <= ch && utf8_ranges[i].end >= ch) {
@@ -611,7 +611,8 @@ static inline zend_bool isualpha(unsigned ch)
                        }
                        return 0;
                }
-       }
+               ++i;
+       );
        return 0;
 }