[PATCH] D45822: [DEBUGINFO, NVPTX] Try to pack bytes data into a single string.

Artem Belevich via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 19 09:55:04 PDT 2018


tra added inline comments.


================
Comment at: lib/MC/MCAsmStreamer.cpp:819-838
+    const char *DirectiveSeparator = MAI->getDirectiveSeparator();
+    if (DirectiveSeparator)
+      OS << Directive;
+    for (const unsigned char C :
+         llvm::make_range(Data.bytes_begin(), std::prev(Data.bytes_end()))) {
+      if (DirectiveSeparator) {
+        OS << (unsigned)C << DirectiveSeparator;
----------------
That's a bit too convoluted, IMO. I think two separate loops would be easier to read:
```
if (DirectiveSeparator) {
  for(const auto C : Data.drop_back(1).bytes())
     OS << C << DirectiveSeparator;
  OS << Data.back();
  EmitEOL();
} else {
   for (const unsigned char C : Data.bytes()) {
     OS << Directive << (unsigned)C;
     EmitEOL();
   }
}
```



Repository:
  rL LLVM

https://reviews.llvm.org/D45822





More information about the llvm-commits mailing list