aho_corasick
aho_corasick copied to clipboard
Refactor API to use std::string_view for efficient substring matching and C-style string compatibility (C++17 required)
Summary:
This pull request refactors the external API to replace std::string with std::string_view in function parameters. This change improves performance when users need to match substrings within large strings or work with C-style strings.
Additionally, this change requires C++17 due to the use of std::string_view, and the CMake configuration has been updated to enforce C++17.
Changes:
- Replaced
std::stringwithstd::string_viewin function signatures. - Ensured compatibility with
std::stringvia implicit conversion tostd::string_view. - Updated CMakeLists.txt to enforce C++17.
Motivation:
The use of std::string_view allows for more efficient substring matching within large strings without unnecessary copying. It also ensures compatibility with C-style strings while maintaining correct functionality when std::string is passed, thanks to implicit conversion to std::string_view.
Compatibility:
- No breaking changes. The API continues to accept
std::stringdue to implicit conversion tostd::string_view. - C++17 is required, as
std::string_viewis introduced in this version.