Skip to content

Commit a33876d

Browse files
committed
[clang-doc] avoid unnecessary string casting and concatenatation
1 parent 322a188 commit a33876d

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

clang-tools-extra/clang-doc/HTMLGenerator.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -517,10 +517,8 @@ writeFileDefinition(const ClangDocContext &CDCtx, const Location &L) {
517517
// The links to a specific line in the source code use the github /
518518
// googlesource notation so it won't work for all hosting pages.
519519
LocNumberNode->Attributes.emplace_back(
520-
"href",
521-
(FileURL + formatv("#{0}{1}", CDCtx.RepositoryLinePrefix.value_or(""),
522-
L.LineNumber))
523-
.str());
520+
"href", formatv("{0}#{1}{2}", FileURL,
521+
CDCtx.RepositoryLinePrefix.value_or(""), L.LineNumber));
524522
Node->Children.emplace_back(std::move(LocNumberNode));
525523
Node->Children.emplace_back(std::make_unique<TextNode>(" of file "));
526524
auto LocFileNode = std::make_unique<TagNode>(

clang-tools-extra/clang-doc/MDGenerator.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,8 @@ static void writeFileDefinition(const ClangDocContext &CDCtx, const Location &L,
6161
} else {
6262

6363
OS << formatv("*Defined at [#{0}{1}{2}](#{0}{1}{3})*",
64-
CDCtx.RepositoryLinePrefix.value_or(""),
65-
std::to_string(L.LineNumber), L.Filename,
66-
StringRef{*CDCtx.RepositoryUrl});
64+
CDCtx.RepositoryLinePrefix.value_or(""), L.LineNumber,
65+
L.Filename, *CDCtx.RepositoryUrl);
6766
}
6867
OS << "\n\n";
6968
}

0 commit comments

Comments
 (0)