mirror of
https://github.com/NixOS/nix.git
synced 2025-11-13 22:12:43 +01:00
Merge pull request #11682 from NaN-git/opt-str
Remove superfluous `std::string` copy operations
This commit is contained in:
commit
30c4f5eb51
16 changed files with 72 additions and 54 deletions
|
|
@ -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 << toView(oss);
|
||||
enqueueMsg(buf.s);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue