Fix do_strip(): don't call PyUnicode_READ() in Py_UNICODE_ISSPACE() to not call
it twice
This commit is contained in:
parent
b3a6014504
commit
9c79e41fc5
@ -11727,16 +11727,23 @@ do_strip(PyObject *self, int striptype)
|
|||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
if (striptype != RIGHTSTRIP) {
|
if (striptype != RIGHTSTRIP) {
|
||||||
while (i < len && Py_UNICODE_ISSPACE(PyUnicode_READ(kind, data, i))) {
|
while (i < len) {
|
||||||
|
Py_UCS4 ch = PyUnicode_READ(kind, data, i);
|
||||||
|
if (!Py_UNICODE_ISSPACE(ch))
|
||||||
|
break;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
j = len;
|
j = len;
|
||||||
if (striptype != LEFTSTRIP) {
|
if (striptype != LEFTSTRIP) {
|
||||||
do {
|
j--;
|
||||||
|
while (j >= i) {
|
||||||
|
Py_UCS4 ch = PyUnicode_READ(kind, data, j);
|
||||||
|
if (!Py_UNICODE_ISSPACE(ch))
|
||||||
|
break;
|
||||||
j--;
|
j--;
|
||||||
} while (j >= i && Py_UNICODE_ISSPACE(PyUnicode_READ(kind, data, j)));
|
}
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user