diff options
author | Ted Kremenek <kremenek@apple.com> | 2008-04-08 22:37:58 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2008-04-08 22:37:58 +0000 |
commit | fa5be3617294f0e3c341f0ecb6b2076478b1b5ac (patch) | |
tree | d92ec56017bf04856dfe0a36e615396fffe93937 /lib/Rewrite/HTMLRewrite.cpp | |
parent | 5dd18b7d5645ddd9bb182c7cf8afc832f5f3a635 (diff) |
Don't expand tabs in EscapeText, but rather expand them when writing out
the HTML file. This should reduce the amount of memory pressure on the
rewriter for files that have a lot of tabs.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49406 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Rewrite/HTMLRewrite.cpp')
-rw-r--r-- | lib/Rewrite/HTMLRewrite.cpp | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/lib/Rewrite/HTMLRewrite.cpp b/lib/Rewrite/HTMLRewrite.cpp index 8bc44e3a81..3e0d71a5b6 100644 --- a/lib/Rewrite/HTMLRewrite.cpp +++ b/lib/Rewrite/HTMLRewrite.cpp @@ -20,7 +20,8 @@ using namespace clang; -void html::EscapeText(Rewriter& R, unsigned FileID, bool EscapeSpaces) { +void html::EscapeText(Rewriter& R, unsigned FileID, + bool EscapeSpaces, bool ReplaceTabs) { const llvm::MemoryBuffer *Buf = R.getSourceMgr().getBuffer(FileID); const char* C = Buf->getBufferStart(); @@ -41,6 +42,9 @@ void html::EscapeText(Rewriter& R, unsigned FileID, bool EscapeSpaces) { break; case '\t': { + if (!ReplaceTabs) + break; + SourceLocation Loc = SourceLocation::getFileLoc(FileID, FilePos); if (EscapeSpaces) @@ -72,7 +76,8 @@ void html::EscapeText(Rewriter& R, unsigned FileID, bool EscapeSpaces) { } } -std::string html::EscapeText(const std::string& s, bool EscapeSpaces) { +std::string html::EscapeText(const std::string& s, bool EscapeSpaces, + bool ReplaceTabs) { unsigned len = s.size(); std::ostringstream os; @@ -90,7 +95,13 @@ std::string html::EscapeText(const std::string& s, bool EscapeSpaces) { else os << ' '; break; - case '\t': for (unsigned i = 0; i < 4; ++i) os << " "; break; + case '\t': + if (ReplaceTabs) + for (unsigned i = 0; i < 4; ++i) os << " "; + else os << c; + + break; + case '<': os << "<"; break; case '>': os << ">"; break; case '&': os << "&"; break; |