Skip to content

Conversation

@scotts
Copy link
Contributor

@scotts scotts commented Jan 13, 2026

Summary: Best practice is to prefer constexpr std::string_view over constexpr char*. In principle, string_views are more efficient to convert to std::string because they include their size in the object and can use a more efficient string constructor. Our benchmark shows the change to be performance neutral, but I still think it's a code improvement.

Differential Revision: D90590675

@meta-cla meta-cla bot added the cla signed label Jan 13, 2026
@meta-codesync
Copy link

meta-codesync bot commented Jan 13, 2026

@scotts has exported this pull request. If you are a Meta employee, you can view the originating Diff in D90590675.

Summary:

Best practice is to prefer `constexpr std::string_view` over `constexpr char*`. In principle, `string_view`s are more efficient to convert to `std::string` because they include their size in the object and can use a more efficient `string` constructor. Our benchmark shows the change to be performance neutral, but I still think it's a code improvement.

Reviewed By: divyanshk

Differential Revision: D90590675
@meta-codesync
Copy link

meta-codesync bot commented Jan 16, 2026

This pull request has been merged in 1d8bcc5.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants