diff options
| author | Chris Lattner <sabre@nondot.org> | 2007-07-24 06:57:14 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2007-07-24 06:57:14 +0000 |
| commit | 4c4a24547561be4785ff36a1a86b87ada9a67c67 (patch) | |
| tree | 075b935425a1e0dbbedf5508569912aa4d6038d2 /clang/Lex/Lexer.cpp | |
| parent | 830a77fd65ce0595217d6c8d9133e6c0efd9fdbd (diff) | |
| download | bcm5719-llvm-4c4a24547561be4785ff36a1a86b87ada9a67c67.tar.gz bcm5719-llvm-4c4a24547561be4785ff36a1a86b87ada9a67c67.zip | |
Use a smallstring instead of an std::string in FileChanged to avoid some malloc traffic.
This speeds up -E on xalancbmk by 2.4%
llvm-svn: 40461
Diffstat (limited to 'clang/Lex/Lexer.cpp')
| -rw-r--r-- | clang/Lex/Lexer.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/clang/Lex/Lexer.cpp b/clang/Lex/Lexer.cpp index f23d34ed422..c45a36a9a59 100644 --- a/clang/Lex/Lexer.cpp +++ b/clang/Lex/Lexer.cpp @@ -92,6 +92,17 @@ std::string Lexer::Stringify(const std::string &Str, bool Charify) { return Result; } +/// Stringify - Convert the specified string into a C string by escaping '\' +/// and " characters. This does not add surrounding ""'s to the string. +void Lexer::Stringify(llvm::SmallVectorImpl<char> &Str) { + for (unsigned i = 0, e = Str.size(); i != e; ++i) { + if (Str[i] == '\\' || Str[i] == '"') { + Str.insert(Str.begin()+i, '\\'); + ++i; ++e; + } + } +} + //===----------------------------------------------------------------------===// // Character information. |

