summaryrefslogtreecommitdiffstats
path: root/clang/Lex
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-07-24 06:57:14 +0000
committerChris Lattner <sabre@nondot.org>2007-07-24 06:57:14 +0000
commit4c4a24547561be4785ff36a1a86b87ada9a67c67 (patch)
tree075b935425a1e0dbbedf5508569912aa4d6038d2 /clang/Lex
parent830a77fd65ce0595217d6c8d9133e6c0efd9fdbd (diff)
downloadbcm5719-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')
-rw-r--r--clang/Lex/Lexer.cpp11
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.
OpenPOWER on IntegriCloud