mirror of
https://github.com/python/cpython.git
synced 2025-08-03 00:23:06 +00:00
bpo-46848: Use stringlib/fastsearch in mmap (GH-31625)
Speed up mmap.find(). Add _PyBytes_Find() and _PyBytes_ReverseFind().
This commit is contained in:
parent
9833bb91e4
commit
6ddb09f35b
4 changed files with 53 additions and 19 deletions
|
@ -116,3 +116,22 @@ PyAPI_FUNC(void*) _PyBytesWriter_WriteBytes(_PyBytesWriter *writer,
|
|||
void *str,
|
||||
const void *bytes,
|
||||
Py_ssize_t size);
|
||||
|
||||
/* Substring Search.
|
||||
|
||||
Returns the index of the first occurence of
|
||||
a substring ("needle") in a larger text ("haystack").
|
||||
If the needle is not found, return -1.
|
||||
If the needle is found, add offset to the index.
|
||||
*/
|
||||
|
||||
PyAPI_FUNC(Py_ssize_t)
|
||||
_PyBytes_Find(const char *haystack, Py_ssize_t len_haystack,
|
||||
const char *needle, Py_ssize_t len_needle,
|
||||
Py_ssize_t offset);
|
||||
|
||||
/* Same as above, but search right-to-left */
|
||||
PyAPI_FUNC(Py_ssize_t)
|
||||
_PyBytes_ReverseFind(const char *haystack, Py_ssize_t len_haystack,
|
||||
const char *needle, Py_ssize_t len_needle,
|
||||
Py_ssize_t offset);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue