Commit dcc7b307 authored by Stefan Behnel's avatar Stefan Behnel

Split uncommon case from unicode/bytes.endswith() implementation to suggest...

Split uncommon case from unicode/bytes.endswith() implementation to suggest inlining the normal case.
parent 7ec6b8a8
...@@ -577,9 +577,8 @@ static CYTHON_INLINE int __Pyx_Py_UNICODE_ISTITLE(Py_UCS4 uchar) ...@@ -577,9 +577,8 @@ static CYTHON_INLINE int __Pyx_Py_UNICODE_ISTITLE(Py_UCS4 uchar)
/////////////// unicode_tailmatch.proto /////////////// /////////////// unicode_tailmatch.proto ///////////////
static int __Pyx_PyUnicode_Tailmatch(PyObject* s, PyObject* substr, static int __Pyx_PyUnicode_Tailmatch(
Py_ssize_t start, Py_ssize_t end, int direction); /*proto*/ PyObject* s, PyObject* substr, Py_ssize_t start, Py_ssize_t end, int direction); /*proto*/
/////////////// unicode_tailmatch /////////////// /////////////// unicode_tailmatch ///////////////
...@@ -587,26 +586,31 @@ static int __Pyx_PyUnicode_Tailmatch(PyObject* s, PyObject* substr, ...@@ -587,26 +586,31 @@ static int __Pyx_PyUnicode_Tailmatch(PyObject* s, PyObject* substr,
// tuple of prefixes/suffixes, whereas it's much more common to // tuple of prefixes/suffixes, whereas it's much more common to
// test for a single unicode string. // test for a single unicode string.
static int __Pyx_PyUnicode_Tailmatch(PyObject* s, PyObject* substr, static int __Pyx_PyUnicode_TailmatchTuple(PyObject* s, PyObject* substrings,
Py_ssize_t start, Py_ssize_t end, int direction) { Py_ssize_t start, Py_ssize_t end, int direction) {
if (unlikely(PyTuple_Check(substr))) { Py_ssize_t i, count = PyTuple_GET_SIZE(substrings);
Py_ssize_t i, count = PyTuple_GET_SIZE(substr); for (i = 0; i < count; i++) {
for (i = 0; i < count; i++) { Py_ssize_t result;
Py_ssize_t result;
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
result = PyUnicode_Tailmatch(s, PyTuple_GET_ITEM(substr, i), result = PyUnicode_Tailmatch(s, PyTuple_GET_ITEM(substrings, i),
start, end, direction); start, end, direction);
#else #else
PyObject* sub = PySequence_ITEM(substr, i); PyObject* sub = PySequence_ITEM(substrings, i);
if (unlikely(!sub)) return -1; if (unlikely(!sub)) return -1;
result = PyUnicode_Tailmatch(s, sub, start, end, direction); result = PyUnicode_Tailmatch(s, sub, start, end, direction);
Py_DECREF(sub); Py_DECREF(sub);
#endif #endif
if (result) { if (result) {
return (int) result; return (int) result;
}
} }
return 0; }
return 0;
}
static int __Pyx_PyUnicode_Tailmatch(PyObject* s, PyObject* substr,
Py_ssize_t start, Py_ssize_t end, int direction) {
if (unlikely(PyTuple_Check(substr))) {
return __Pyx_PyUnicode_TailmatchTuple(s, substr, start, end, direction);
} }
return (int) PyUnicode_Tailmatch(s, substr, start, end, direction); return (int) PyUnicode_Tailmatch(s, substr, start, end, direction);
} }
...@@ -677,26 +681,31 @@ static int __Pyx_PyBytes_SingleTailmatch(PyObject* self, PyObject* arg, ...@@ -677,26 +681,31 @@ static int __Pyx_PyBytes_SingleTailmatch(PyObject* self, PyObject* arg,
return retval; return retval;
} }
static int __Pyx_PyBytes_Tailmatch(PyObject* self, PyObject* substr, static int __Pyx_PyBytes_TailmatchTuple(PyObject* self, PyObject* substrings,
Py_ssize_t start, Py_ssize_t end, int direction) { Py_ssize_t start, Py_ssize_t end, int direction) {
if (unlikely(PyTuple_Check(substr))) { Py_ssize_t i, count = PyTuple_GET_SIZE(substrings);
Py_ssize_t i, count = PyTuple_GET_SIZE(substr); for (i = 0; i < count; i++) {
for (i = 0; i < count; i++) { int result;
int result;
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
result = __Pyx_PyBytes_SingleTailmatch(self, PyTuple_GET_ITEM(substr, i), result = __Pyx_PyBytes_SingleTailmatch(self, PyTuple_GET_ITEM(substrings, i),
start, end, direction); start, end, direction);
#else #else
PyObject* sub = PySequence_ITEM(substr, i); PyObject* sub = PySequence_ITEM(substrings, i);
if (unlikely(!sub)) return -1; if (unlikely(!sub)) return -1;
result = __Pyx_PyBytes_SingleTailmatch(self, sub, start, end, direction); result = __Pyx_PyBytes_SingleTailmatch(self, sub, start, end, direction);
Py_DECREF(sub); Py_DECREF(sub);
#endif #endif
if (result) { if (result) {
return result; return result;
}
} }
return 0; }
return 0;
}
static int __Pyx_PyBytes_Tailmatch(PyObject* self, PyObject* substr,
Py_ssize_t start, Py_ssize_t end, int direction) {
if (unlikely(PyTuple_Check(substr))) {
return __Pyx_PyBytes_TailmatchTuple(self, substr, start, end, direction);
} }
return __Pyx_PyBytes_SingleTailmatch(self, substr, start, end, direction); return __Pyx_PyBytes_SingleTailmatch(self, substr, start, end, direction);
......
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