summaryrefslogtreecommitdiffstats
path: root/Include/cpython
diff options
context:
space:
mode:
authorDennis Sweeney <36520290+sweeneyde@users.noreply.github.com>2022-03-02 04:46:30 (GMT)
committerGitHub <noreply@github.com>2022-03-02 04:46:30 (GMT)
commit6ddb09f35b922a3bbb59e408a3ca7636a6938468 (patch)
tree26b0fbc0a99455f9393e5570ef884999e792ba93 /Include/cpython
parent9833bb91e4d5c2606421d9ec2085f5c2dfb6f72c (diff)
downloadcpython-6ddb09f35b922a3bbb59e408a3ca7636a6938468.zip
cpython-6ddb09f35b922a3bbb59e408a3ca7636a6938468.tar.gz
cpython-6ddb09f35b922a3bbb59e408a3ca7636a6938468.tar.bz2
bpo-46848: Use stringlib/fastsearch in mmap (GH-31625)
Speed up mmap.find(). Add _PyBytes_Find() and _PyBytes_ReverseFind().
Diffstat (limited to 'Include/cpython')
-rw-r--r--Include/cpython/bytesobject.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/Include/cpython/bytesobject.h b/Include/cpython/bytesobject.h
index 6b3f552..38a0fe0 100644
--- a/Include/cpython/bytesobject.h
+++ b/Include/cpython/bytesobject.h
@@ -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);