Use a smallstring instead of an std::string in FileChanged to avoid some malloc traffic.
This speeds up -E on xalancbmk by 2.4%
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40461 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Driver/PrintPreprocessedOutput.cpp b/Driver/PrintPreprocessedOutput.cpp
index d5c5b9a..a8bc4e4 100644
--- a/Driver/PrintPreprocessedOutput.cpp
+++ b/Driver/PrintPreprocessedOutput.cpp
@@ -18,6 +18,7 @@
#include "clang/Lex/Pragma.h"
#include "clang/Basic/SourceManager.h"
#include "llvm/Support/CommandLine.h"
+#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Config/config.h"
#include <cstdio>
@@ -123,13 +124,13 @@
class PrintPPOutputPPCallbacks : public PPCallbacks {
Preprocessor &PP;
unsigned CurLine;
- std::string CurFilename;
bool EmittedTokensOnThisLine;
DirectoryLookup::DirType FileType;
+ llvm::SmallString<512> CurFilename;
public:
PrintPPOutputPPCallbacks(Preprocessor &pp) : PP(pp) {
CurLine = 0;
- CurFilename = "<uninit>";
+ CurFilename += "<uninit>";
EmittedTokensOnThisLine = false;
FileType = DirectoryLookup::NormalHeaderDir;
}
@@ -237,7 +238,9 @@
Loc = SourceMgr.getLogicalLoc(Loc);
CurLine = SourceMgr.getLineNumber(Loc);
- CurFilename = Lexer::Stringify(SourceMgr.getSourceName(Loc));
+ CurFilename.clear();
+ CurFilename += SourceMgr.getSourceName(Loc);
+ Lexer::Stringify(CurFilename);
FileType = FileType;
if (EmittedTokensOnThisLine) {