Fix do_strip(): don't call PyUnicode_READ() in Py_UNICODE_ISSPACE() to not call

it twice
This commit is contained in:
Victor Stinner 2013-04-09 22:21:08 +02:00
parent b3a6014504
commit 9c79e41fc5

View File

@ -11727,16 +11727,23 @@ do_strip(PyObject *self, int striptype)
i = 0;
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++;
}
}
j = len;
if (striptype != LEFTSTRIP) {
do {
j--;
while (j >= i) {
Py_UCS4 ch = PyUnicode_READ(kind, data, j);
if (!Py_UNICODE_ISSPACE(ch))
break;
j--;
} while (j >= i && Py_UNICODE_ISSPACE(PyUnicode_READ(kind, data, j)));
}
j++;
}