]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
bpo-41972: Use the two-way algorithm for string searching (GH-22904)
authorDennis Sweeney <36520290+sweeneyde@users.noreply.github.com>
Sun, 28 Feb 2021 18:20:50 +0000 (13:20 -0500)
committerGitHub <noreply@github.com>
Sun, 28 Feb 2021 18:20:50 +0000 (12:20 -0600)
commit73a85c4e1da42db28e3de57c868d24a089b8d277
treeed2b044a2b8bd42bb611922bbcacbaf3599e91f9
parent2183d06bc8a481098d62a4ebed8d6982b3d1602a
bpo-41972: Use the two-way algorithm for string searching (GH-22904)

Implement an enhanced variant of Crochemore and Perrin's Two-Way string searching algorithm, which reduces worst-case time from quadratic (the product of the string and pattern lengths) to linear. This applies to forward searches (like``find``, ``index``, ``replace``); the algorithm for reverse searches (like ``rfind``) is not changed.

Co-authored-by: Tim Peters <tim.peters@gmail.com>
Lib/test/string_tests.py
Misc/NEWS.d/next/Core and Builtins/2020-10-23-23-17-23.bpo-41972.kbAwg4.rst [new file with mode: 0644]
Objects/stringlib/fastsearch.h
Objects/stringlib/stringlib_find_two_way_notes.txt [new file with mode: 0644]