elsteveogrande marked an inline comment as done.
elsteveogrande added inline comments.


> majnemer wrote in PrintPreprocessedOutput.cpp:331-349
> I think this loop would be easier to understand like so:
> 
>   while (!Path.empty()) {
>     if (Path.consume_front("\\")) {
>       Buffer.push_back("\\\\");
>     } else if (Path.consume_front("\"")) {
>       Buffer.push_back("\\\"");
>     } else if (Path.consume_front("*/")) {
>       Buffer.push_back("*\\/");
>     } else {
>       Buffer.push_back(Path.front());
>       Path = Path.drop_front();
>     }
>   }
> 
> The big takeaway is that we now avoid messy `I + 1 < N` type checks.

yes!  I like this much better, thanks.  Didn't know about that method, very 
handy.

Also at the risk of changing more stuff and possibly churning more (thank you 
for sticking with me this long!) I'll change it to use either a 
`std::stringstream`, or `std::string` with `operator+=` to build it up.

A `std::vector<char>` won't take additional strings `push_back`'ed like that, 
and while it's more handy than `char[]`, it's slightly weird, when this is 
stringstream's purpose, imho.

https://reviews.llvm.org/D25153



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to