Skip to content

Commit

Permalink
More string_view
Browse files Browse the repository at this point in the history
  • Loading branch information
ken-matsui committed Feb 2, 2024
1 parent 6482192 commit a040507
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Cmd/Tidy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 5 additions & 3 deletions src/VersionReq.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/VersionReq.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down

0 comments on commit a040507

Please sign in to comment.