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

Remove superfluous std::string copy operations #11682

Merged
merged 5 commits into from
Oct 12, 2024
Merged

Conversation

NaN-git
Copy link

@NaN-git NaN-git commented Oct 11, 2024

Motivation

Nix uses std::string in many places. Often those are copied around, although this is not necessary because std::string_view can be used instead.

Also for most regex related code std::string_view is sufficent, too.

Context

Nix has leftovers from code, which used C-strings in the past. Some of these leftovers are fixed.

C++20 adds the view() member function to std::basic_ostringstream. Sadly, the libc++ library shipped with clang-16 does not implement this and clang-17 would be required. Thus a workaround is implemented to get a std::string_view from std::ostringstream.

The PR reduces closure size by ~50KB. When evaluating nixpkgs I couldn't measure a significant performance difference.

Priorities and Process

Add 👍 to pull requests you find important.

The Nix maintainer team uses a GitHub project board to schedule and track reviews.

@github-actions github-actions bot added new-cli Relating to the "nix" command repl The Read Eval Print Loop, "nix repl" command and debugger labels Oct 11, 2024
Copy link
Member

@roberth roberth left a comment

Choose a reason for hiding this comment

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

Thank you!

@roberth roberth merged commit 30c4f5e into NixOS:master Oct 12, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new-cli Relating to the "nix" command repl The Read Eval Print Loop, "nix repl" command and debugger
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants