Skip to content

Commit 2ea98a0

Browse files
committed
fix review findings
1 parent f2e9154 commit 2ea98a0

File tree

2 files changed

+10
-14
lines changed

2 files changed

+10
-14
lines changed

clang-tools-extra/clangd/support/Markup.cpp

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -476,11 +476,10 @@ std::string Block::asPlainText() const {
476476
}
477477

478478
void Paragraph::renderNewlinesMarkdown(llvm::raw_ostream &OS,
479-
std::string &ParagraphText) const {
479+
llvm::StringRef ParagraphText) const {
480480
llvm::StringRef Line, Rest;
481481

482-
for (std::tie(Line, Rest) =
483-
llvm::StringRef(ParagraphText).ltrim("\n").rtrim().split('\n');
482+
for (std::tie(Line, Rest) = ParagraphText.ltrim("\n").rtrim().split('\n');
484483
!(Line.empty() && Rest.empty());
485484
std::tie(Line, Rest) = Rest.split('\n')) {
486485

@@ -614,11 +613,8 @@ bool Paragraph::isHardLineBreakIndicator(llvm::StringRef Rest,
614613
if (Rest.empty())
615614
return false;
616615

617-
if (IsMarkdown) {
618-
if (LinebreakIndicatorsMarkdown.contains(Rest.front()))
619-
return true;
620-
return false;
621-
}
616+
if (IsMarkdown)
617+
return LinebreakIndicatorsMarkdown.contains(Rest.front());
622618

623619
if (LinebreakIndicatorsPlainText.contains(Rest.front()))
624620
return true;
@@ -634,15 +630,15 @@ bool Paragraph::isHardLineBreakIndicator(llvm::StringRef Rest,
634630
bool Paragraph::isHardLineBreakAfter(llvm::StringRef Line, llvm::StringRef Rest,
635631
bool IsMarkdown) const {
636632
// Should we also consider whether Line is short?
637-
return (punctuationIndicatesLineBreak(Line, IsMarkdown) ||
638-
isHardLineBreakIndicator(Rest, IsMarkdown));
633+
return punctuationIndicatesLineBreak(Line, IsMarkdown) ||
634+
isHardLineBreakIndicator(Rest, IsMarkdown);
639635
}
640636

641637
void Paragraph::renderNewlinesPlaintext(llvm::raw_ostream &OS,
642-
std::string &ParagraphText) const {
638+
llvm::StringRef ParagraphText) const {
643639
llvm::StringRef Line, Rest;
644640

645-
for (std::tie(Line, Rest) = llvm::StringRef(ParagraphText).trim().split('\n');
641+
for (std::tie(Line, Rest) = ParagraphText.trim().split('\n');
646642
!(Line.empty() && Rest.empty());
647643
std::tie(Line, Rest) = Rest.split('\n')) {
648644

clang-tools-extra/clangd/support/Markup.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ class Paragraph : public Block {
144144
/// \param OS The stream to render to.
145145
/// \param ParagraphText The text of the paragraph to render.
146146
void renderNewlinesMarkdown(llvm::raw_ostream &OS,
147-
std::string &ParagraphText) const;
147+
llvm::StringRef ParagraphText) const;
148148

149149
/// \brief Go through the contents line by line to handle the newlines
150150
/// and required spacing correctly for plain text rendering.
@@ -169,7 +169,7 @@ class Paragraph : public Block {
169169
/// \param OS The stream to render to.
170170
/// \param ParagraphText The text of the paragraph to render.
171171
void renderNewlinesPlaintext(llvm::raw_ostream &OS,
172-
std::string &ParagraphText) const;
172+
llvm::StringRef ParagraphText) const;
173173
};
174174

175175
/// Represents a sequence of one or more documents. Knows how to print them in a

0 commit comments

Comments
 (0)