Skip to content

Conversation

@natecook1000
Copy link
Member

Cherry-pick of #715 for the swift/main branch.

* Add a string-specific search algorithm This adds a Boyer-Moore substring search algorithm, and updates the `firstRange(of:)` and `ranges(of:)` methods to use that when both pieces of the search are strings/substrings. * Substring search: iterative rather than recursive For large strings, a recursive search can run out of stack space. This eliminates the issue by looping within the `nextRange` function. * Dispatch string splitting to new searcher * Remove generic on SubstringSearcher * Remove unnecessary inlining annotations * Update string algorithms tests * Verify string/substring dispatch in algorithms * Add tests for string.replacing maxReplacements * Add fallback to naive search for small patterns * Improve some comments/formatting in the string search
@natecook1000
Copy link
Member Author

@swift-ci Please test

@natecook1000
Copy link
Member Author

@swift-ci Please test

@stephentyrone stephentyrone merged commit 5c93227 into swift/main Jul 10, 2024
@stephentyrone stephentyrone deleted the swiftmain_search-algorithm branch July 10, 2024 15:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants