diff options
author | Jade Lovelace <lix@jade.fyi> | 2024-07-23 21:45:30 +0200 |
---|---|---|
committer | Jade Lovelace <lix@jade.fyi> | 2024-07-23 21:45:30 +0200 |
commit | 12a5838d11f790d36e2ac626e8916a2c19bcb80b (patch) | |
tree | 34a50d0010e710a3a96fde71b24ce44833e66aeb /src/nix/diff-closures.cc | |
parent | 2436f2110af7cf305ebe5198e5e330cfcdd3a2c6 (diff) |
diff-closures: remove gratuitous copy
This was done originally because std::smatch does not accept `const char
*` as iterators. However, this was because we should have been using
std::cmatch instead.
Change-Id: Ibe73851fd39755e883df2d33d22fed72ac0a04ae
Diffstat (limited to 'src/nix/diff-closures.cc')
-rw-r--r-- | src/nix/diff-closures.cc | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/src/nix/diff-closures.cc b/src/nix/diff-closures.cc index 5eda309d5..dac4625e6 100644 --- a/src/nix/diff-closures.cc +++ b/src/nix/diff-closures.cc @@ -24,24 +24,17 @@ GroupedPaths getClosureInfo(ref<Store> store, const StorePath & toplevel) GroupedPaths groupedPaths; - for (auto & path : closure) { + for (auto const & path : closure) { /* Strip the output name. Unfortunately this is ambiguous (we can't distinguish between output names like "bin" and version suffixes like "unstable"). */ static std::regex regex("(.*)-([a-z]+|lib32|lib64)"); - std::smatch match; + std::cmatch match; std::string name{path.name()}; - // Used to keep name alive through being potentially overwritten below - // (to not invalidate the references from the regex result) - // - // n.b. cannot be just path.name().{begin,end}() since that returns const - // char *, which does not, for some reason, convert as required on - // libstdc++. Seems like a libstdc++ bug or standard bug to me... we - // can afford the allocation in any case. - const std::string origName{path.name()}; + std::string_view const origName = path.name(); std::string outputName; - if (std::regex_match(origName, match, regex)) { + if (std::regex_match(origName.begin(), origName.end(), match, regex)) { name = match[1]; outputName = match[2]; } |