summaryrefslogtreecommitdiff
path: root/Objects/stringlib/partition.h
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2010-01-02 21:40:36 +0000
committerAntoine Pitrou <solipsis@pitrou.net>2010-01-02 21:40:36 +0000
commitda2ecaf3349d564ef0392183d86270eea5cdb439 (patch)
treed30ed807e0e325a492f999576bf19fd370b0dbda /Objects/stringlib/partition.h
parent2952148dd246b67ca88a68c44819a208d0d6624a (diff)
downloadcpython-git-da2ecaf3349d564ef0392183d86270eea5cdb439.tar.gz
Merged revisions 77241 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r77241 | antoine.pitrou | 2010-01-02 22:12:58 +0100 (sam., 02 janv. 2010) | 4 lines Issue #7462: Implement the stringlib fast search algorithm for the `rfind`, `rindex`, `rsplit` and `rpartition` methods. Patch by Florent Xicluna. ........
Diffstat (limited to 'Objects/stringlib/partition.h')
-rw-r--r--Objects/stringlib/partition.h12
1 files changed, 3 insertions, 9 deletions
diff --git a/Objects/stringlib/partition.h b/Objects/stringlib/partition.h
index 105ba317d6..2f26212983 100644
--- a/Objects/stringlib/partition.h
+++ b/Objects/stringlib/partition.h
@@ -58,7 +58,7 @@ stringlib_rpartition(
)
{
PyObject* out;
- Py_ssize_t pos, j;
+ Py_ssize_t pos;
if (sep_len == 0) {
PyErr_SetString(PyExc_ValueError, "empty separator");
@@ -69,20 +69,14 @@ stringlib_rpartition(
if (!out)
return NULL;
- /* XXX - create reversefastsearch helper! */
- pos = -1;
- for (j = str_len - sep_len; j >= 0; --j)
- if (STRINGLIB_CMP(str+j, sep, sep_len) == 0) {
- pos = j;
- break;
- }
+ pos = fastsearch(str, str_len, sep, sep_len, FAST_RSEARCH);
if (pos < 0) {
Py_INCREF(STRINGLIB_EMPTY);
PyTuple_SET_ITEM(out, 0, (PyObject*) STRINGLIB_EMPTY);
Py_INCREF(STRINGLIB_EMPTY);
PyTuple_SET_ITEM(out, 1, (PyObject*) STRINGLIB_EMPTY);
- Py_INCREF(str_obj);
+ Py_INCREF(str_obj);
PyTuple_SET_ITEM(out, 2, (PyObject*) str_obj);
return out;
}