[PATCH] D39279: Stringizing raw string literals containing newline
Jan Korous via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 24 04:56:23 PST 2017
jkorous-apple added inline comments.
================
Comment at: lib/Lex/Lexer.cpp:217
+void StringifyImpl(T& Str, char Quote) {
+ unsigned i = 0, e = Str.size();
+ while (i < e) {
----------------
Wouldn't **auto** or **typename T::size_type** instead of **unsigned** be more appropriate here?
Both of your supported use cases have this member type.
http://llvm.org/doxygen/classllvm_1_1StringRef.html#a54e59e2d53e5ee736ee060be7c457508
http://llvm.org/doxygen/classllvm_1_1SmallVectorImpl.html#acc72e8846802a1e703501219cf19458e
================
Comment at: lib/Lex/Lexer.cpp:231
+ Str.erase(Str.begin() + i, Str.begin() + i + Size);
+ Str.insert(Str.begin() + i, '\\');
+ Str.insert(Str.begin() + i + 1, 'n');
----------------
I am just wondering if potential performance benefit of counting all the extra space in advance and resizing the string just once might be interesting here.
Basically with current approach characters at the end of the string are moved as many times as there are endlines in the string.
https://reviews.llvm.org/D39279
More information about the cfe-commits
mailing list