aboutsummaryrefslogtreecommitdiff
path: root/include/clang/Basic/SourceManager.h
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-07-24 05:57:19 +0000
committerChris Lattner <sabre@nondot.org>2007-07-24 05:57:19 +0000
commit5e36a7a89da5d69ece23fc8228624a053f75c645 (patch)
tree094c1ab2abd4c1ddf3974d2cfca2e8d3fc7d473c /include/clang/Basic/SourceManager.h
parentb638a309b61ccb80cd4c437b578d25d92f948fbf (diff)
Add a cache to SourceManager to accellerate line # lookup. This is a
bottleneck for -E computation, because every token that starts a line needs to determine *which* line it is on (so -E mode can insert the appropriate vertical whitespace). This optimization improves this common case where it is striding through the line # table. This speeds up -E on xalancbmk by 3.2% git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40459 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Basic/SourceManager.h')
-rw-r--r--include/clang/Basic/SourceManager.h10
1 files changed, 9 insertions, 1 deletions
diff --git a/include/clang/Basic/SourceManager.h b/include/clang/Basic/SourceManager.h
index f06a6fbf54..dd8a86cc7e 100644
--- a/include/clang/Basic/SourceManager.h
+++ b/include/clang/Basic/SourceManager.h
@@ -154,13 +154,21 @@ class SourceManager {
/// MacroIDs - Information about each MacroID.
std::vector<SrcMgr::MacroIDInfo> MacroIDs;
+ /// LastLineNo - These ivars serve as a cache used in the getLineNumber
+ /// method which is used to speedup getLineNumber calls to nearby locations.
+ unsigned LastLineNoFileIDQuery;
+ SrcMgr::FileInfo *LastLineNoFileInfo;
+ unsigned LastLineNoFilePos;
+ unsigned LastLineNoResult;
public:
- SourceManager() {}
+ SourceManager() : LastLineNoFileIDQuery(~0U) {}
~SourceManager();
void clearIDTables() {
FileIDs.clear();
MacroIDs.clear();
+ LastLineNoFileIDQuery = ~0U;
+ LastLineNoFileInfo = 0;
}
/// createFileID - Create a new FileID that represents the specified file