Commit 593bb30e authored by Sergey Fedoseev's avatar Sergey Fedoseev Committed by Benjamin Peterson

closes bpo-34599: Improve performance of _Py_bytes_capitalize(). (GH-9083)

parent b03c2c51
......@@ -361,23 +361,9 @@ and the rest lower-cased.");
void
_Py_bytes_capitalize(char *result, const char *s, Py_ssize_t len)
{
Py_ssize_t i;
if (0 < len) {
int c = Py_CHARMASK(*s++);
if (Py_ISLOWER(c))
*result = Py_TOUPPER(c);
else
*result = c;
result++;
}
for (i = 1; i < len; i++) {
int c = Py_CHARMASK(*s++);
if (Py_ISUPPER(c))
*result = Py_TOLOWER(c);
else
*result = c;
result++;
if (len > 0) {
*result = Py_TOUPPER(*s);
_Py_bytes_lower(result + 1, s + 1, len - 1);
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment