diff --git a/src/Cmd/Tidy.cc b/src/Cmd/Tidy.cc index 3f57404e3..4d9c1c5e4 100644 --- a/src/Cmd/Tidy.cc +++ b/src/Cmd/Tidy.cc @@ -22,7 +22,7 @@ const Subcmd TIDY_CMD = .setMainFn(tidyMain); static int -tidyImpl(const String& makeCmd) { +tidyImpl(const StringRef makeCmd) { const auto start = std::chrono::steady_clock::now(); const int exitCode = execCmd(makeCmd); diff --git a/src/VersionReq.cc b/src/VersionReq.cc index 224faeb9c..83f326612 100644 --- a/src/VersionReq.cc +++ b/src/VersionReq.cc @@ -821,15 +821,17 @@ VersionReq::toString() const noexcept { } String -VersionReq::toPkgConfigString(const String& name) const noexcept { +VersionReq::toPkgConfigString(const StringRef name) const noexcept { // For pkg-config, canonicalization is necessary. const VersionReq req = canonicalize(); - String result = name; + String result(name); result += ' '; result += req.left.toPkgConfigString(); if (req.right.has_value()) { - result += ", " + name + ' '; + result += ", "; + result += name; + result += ' '; result += req.right->toPkgConfigString(); } return result; diff --git a/src/VersionReq.hpp b/src/VersionReq.hpp index 49773a2cc..ba5480922 100644 --- a/src/VersionReq.hpp +++ b/src/VersionReq.hpp @@ -89,7 +89,7 @@ struct VersionReq { static VersionReq parse(StringRef str); bool satisfiedBy(const Version& ver) const noexcept; String toString() const noexcept; - String toPkgConfigString(const String& name) const noexcept; + String toPkgConfigString(StringRef name) const noexcept; VersionReq canonicalize() const noexcept; bool canSimplify() const noexcept; };