aho_corasick icon indicating copy to clipboard operation
aho_corasick copied to clipboard

Refactor API to use std::string_view for efficient substring matching and C-style string compatibility (C++17 required)

Open LouisLou2 opened this issue 1 year ago • 0 comments

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::string with std::string_view in function signatures.
  • Ensured compatibility with std::string via implicit conversion to std::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::string due to implicit conversion to std::string_view.
  • C++17 is required, as std::string_view is introduced in this version.

LouisLou2 avatar Nov 14 '24 15:11 LouisLou2