[clang-tools-extra] [clangd] Improve Markup Rendering (PR #140498)

Maksim Ivanov via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 11 19:45:16 PDT 2025


================
@@ -420,29 +636,44 @@ Paragraph &Paragraph::appendSpace() {
   return *this;
 }
 
-Paragraph &Paragraph::appendText(llvm::StringRef Text) {
-  std::string Norm = canonicalizeSpaces(Text);
-  if (Norm.empty())
+Paragraph &Paragraph::appendChunk(llvm::StringRef Contents, ChunkKind K) {
+  if (Contents.empty())
     return *this;
   Chunks.emplace_back();
   Chunk &C = Chunks.back();
-  C.Contents = std::move(Norm);
-  C.Kind = Chunk::PlainText;
-  C.SpaceBefore = llvm::isSpace(Text.front());
-  C.SpaceAfter = llvm::isSpace(Text.back());
+  C.Contents = std::move(Contents);
----------------
emaxx-google wrote:

nit: `std::move()` isn't really making a difference here, when an `std::string` is allocated anyway in order to copy the contents of `StringRef`.

Ditto in other places before that apply `std::move()` to `StringRef`.

https://github.com/llvm/llvm-project/pull/140498


More information about the cfe-commits mailing list