Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[onert] Apply std::string_view #14697

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ragmani
Copy link
Contributor

@ragmani ragmani commented Feb 18, 2025

This commit applies std::string_view in places where there is a performance benefit.

ONE-DCO-1.0-Signed-off-by: ragmani [email protected]

This commit applies std::string_view in places where there is a performance benefit.

ONE-DCO-1.0-Signed-off-by: ragmani <[email protected]>
@ragmani ragmani added the PR/ready for review It is ready to review. Please review it. label Feb 18, 2025
@ragmani ragmani requested a review from a team February 18, 2025 11:25
{
std::string whitespace = " \t";
constexpr std::string_view whitespace = " \t";
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In C++20, many member functions of std::string_view (including find_first_not_of) are declared as constexpr and can be evaluated at compile time if given constant expressions. However, for std::string, prior to C++20 its member functions (including find_first_not_of) are not constexpr and thus cannot be used as compile-time constants. In short, find_first_not_of can be a compile‐time constant when used with types that support constexpr evaluation (like std::string_view in C++20), but not in general.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR/ready for review It is ready to review. Please review it.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant