Skip to content

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

Open
LouisLou2 wants to merge 2 commits into
cjgdev:masterfrom
LouisLou2:master
Open

Refactor API to use std::string_view for efficient substring matching and C-style string compatibility (C++17 required)#23
LouisLou2 wants to merge 2 commits into
cjgdev:masterfrom
LouisLou2:master

Conversation

@LouisLou2
Copy link
Copy Markdown

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant