1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-14 06:22:42 +01:00

cont. cleanup: remove superfluous std::string copies

This commit is contained in:
Philipp Otterbein 2024-10-07 01:05:17 +02:00
parent 4c0c8e5428
commit caf3b55891
6 changed files with 21 additions and 17 deletions

View file

@ -90,11 +90,11 @@ struct TunnelLogger : public Logger
{
if (ei.level > verbosity) return;
std::stringstream oss;
std::ostringstream oss;
showErrorInfo(oss, ei, false);
StringSink buf;
buf << STDERR_NEXT << oss.str();
buf << STDERR_NEXT << oss.view();
enqueueMsg(buf.s);
}

View file

@ -30,16 +30,15 @@ std::optional<OutputsSpec> OutputsSpec::parseOpt(std::string_view s)
{
static std::regex regex(std::string { outputSpecRegexStr });
std::smatch match;
std::string s2 { s }; // until some improves std::regex
if (!std::regex_match(s2, match, regex))
std::cmatch match;
if (!std::regex_match(s.cbegin(), s.cend(), match, regex))
return std::nullopt;
if (match[1].matched)
return { OutputsSpec::All {} };
if (match[2].matched)
return OutputsSpec::Names { tokenizeString<StringSet>(match[2].str(), ",") };
return OutputsSpec::Names { tokenizeString<StringSet>({match[2].first, match[2].second}, ",") };
assert(false);
}