Skip to content

Commit a233e12

Browse files
committed
Use ascii lowercase if locale is default C
1 parent 11491b6 commit a233e12

File tree

1 file changed

+22
-18
lines changed

1 file changed

+22
-18
lines changed

ext/standard/string.c

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1462,29 +1462,33 @@ PHPAPI zend_string *php_string_tolower(zend_string *s)
14621462
unsigned char *c;
14631463
const unsigned char *e;
14641464

1465-
c = (unsigned char *)ZSTR_VAL(s);
1466-
e = c + ZSTR_LEN(s);
1465+
if (EXPECTED(!BG(locale_changed))) {
1466+
return zend_string_tolower(s);
1467+
} else {
1468+
c = (unsigned char *)ZSTR_VAL(s);
1469+
e = c + ZSTR_LEN(s);
14671470

1468-
while (c < e) {
1469-
if (isupper(*c)) {
1470-
register unsigned char *r;
1471-
zend_string *res = zend_string_alloc(ZSTR_LEN(s), 0);
1471+
while (c < e) {
1472+
if (isupper(*c)) {
1473+
register unsigned char *r;
1474+
zend_string *res = zend_string_alloc(ZSTR_LEN(s), 0);
14721475

1473-
if (c != (unsigned char*)ZSTR_VAL(s)) {
1474-
memcpy(ZSTR_VAL(res), ZSTR_VAL(s), c - (unsigned char*)ZSTR_VAL(s));
1475-
}
1476-
r = c + (ZSTR_VAL(res) - ZSTR_VAL(s));
1477-
while (c < e) {
1478-
*r = tolower(*c);
1479-
r++;
1480-
c++;
1476+
if (c != (unsigned char*)ZSTR_VAL(s)) {
1477+
memcpy(ZSTR_VAL(res), ZSTR_VAL(s), c - (unsigned char*)ZSTR_VAL(s));
1478+
}
1479+
r = c + (ZSTR_VAL(res) - ZSTR_VAL(s));
1480+
while (c < e) {
1481+
*r = tolower(*c);
1482+
r++;
1483+
c++;
1484+
}
1485+
*r = '\0';
1486+
return res;
14811487
}
1482-
*r = '\0';
1483-
return res;
1488+
c++;
14841489
}
1485-
c++;
1490+
return zend_string_copy(s);
14861491
}
1487-
return zend_string_copy(s);
14881492
}
14891493
/* }}} */
14901494

0 commit comments

Comments
 (0)