mirror of
https://github.com/python/cpython.git
synced 2025-09-13 04:08:37 +00:00
closes bpo-34599: Improve performance of _Py_bytes_capitalize(). (GH-9083)
This commit is contained in:
parent
b03c2c5190
commit
593bb30e82
1 changed files with 3 additions and 17 deletions
|
@ -361,23 +361,9 @@ and the rest lower-cased.");
|
||||||
void
|
void
|
||||||
_Py_bytes_capitalize(char *result, const char *s, Py_ssize_t len)
|
_Py_bytes_capitalize(char *result, const char *s, Py_ssize_t len)
|
||||||
{
|
{
|
||||||
Py_ssize_t i;
|
if (len > 0) {
|
||||||
|
*result = Py_TOUPPER(*s);
|
||||||
if (0 < len) {
|
_Py_bytes_lower(result + 1, s + 1, len - 1);
|
||||||
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++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue