com php-src: Unroll loop for ASCII check: win32/codepage.c
| From: | Anatol Belski | Date: | Wed, 15 Nov 2017 15:02:46 +0000 |
| Subject: | com php-src: Unroll loop for ASCII check: win32/codepage.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-100262@lists.php.net to get a copy of this message | ||
Commit: 178add7a583c84de1e2c7b5ef1d6c103755ab555
Author: Anatol Belski <ab@php.net> Wed, 15 Nov 2017 16:00:15 +0100
Parents: c6d0c8aa3bac0a4e66b94960863b1f6d49420d7d
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=178add7a583c84de1e2c7b5ef1d6c103755ab555
Log:
Unroll loop for ASCII check
Changed paths:
M win32/codepage.c
Diff:
diff --git a/win32/codepage.c b/win32/codepage.c
index aa57892..ab6d0a1 100644
--- a/win32/codepage.c
+++ b/win32/codepage.c
@@ -97,6 +97,7 @@ PW32CP wchar_t *php_win32_cp_conv_ascii_to_w(const char* in, size_t in_len, size
{/*{{{*/
wchar_t *ret = NULL;
const char *idx = in, *end;
+ BOOL failed = FALSE;
assert(in && in_len ? in[in_len] == '\0' : 1);
@@ -114,14 +115,37 @@ PW32CP wchar_t *php_win32_cp_conv_ascii_to_w(const char* in, size_t in_len,
size
end = in + in_len;
- while (idx != end) {
- if (!__isascii(*idx) && '\0' != *idx) {
+ while (end - idx > 8) {
+ char ch0 = *idx;
+ char ch1 = *(idx + 1);
+ char ch2 = *(idx + 2);
+ char ch3 = *(idx + 3);
+ char ch4 = *(idx + 4);
+ char ch5 = *(idx + 5);
+ char ch6 = *(idx + 6);
+ char ch7 = *(idx + 7);
+
+ if (!__isascii(ch0) || !__isascii(ch1) || !__isascii(ch2) || !__isascii(ch3) ||
+ !__isascii(ch4) || !__isascii(ch5) || !__isascii(ch6) || !__isascii(ch7)) {
+ failed = TRUE;
break;
}
- idx++;
+
+ idx += 8;
+ }
+
+ /* Finish the job on remaining chars. */
+ if (!failed) {
+ while (idx != end) {
+ if (!__isascii(*idx) && '\0' != *idx) {
+ failed = TRUE;
+ break;
+ }
+ idx++;
+ }
}
- if (idx == end) {
+ if (!failed) {
size_t i = 0;
int k = 0;
wchar_t *ret_idx;