mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Cache results of visible decl lookup at top-level in a TranslationUnit.
This is a tradeoff, assuming that lookup in a particular module is less likely to be repeated than lookup within the current source file. By storing the cached results with the TU's own local lookup cache, the results get cleared out when we parse additional decls. Since this is only used by code completion, there's no performance benefit for the compiler, or even for swift-ide-test...it's only in repeated lookups that this will be useful. Swift SVN r7169
This commit is contained in:
@@ -104,6 +104,8 @@ namespace {
|
||||
VisibleDeclConsumer &Consumer,
|
||||
NLKind LookupKind,
|
||||
const TranslationUnit &TU);
|
||||
|
||||
SmallVector<ValueDecl *, 0> AllVisibleValues;
|
||||
};
|
||||
} // end anonymous namespace.
|
||||
|
||||
@@ -416,6 +418,17 @@ void TranslationUnit::clearLookupCache() {
|
||||
freeTUCachePimpl(LookupCachePimpl);
|
||||
}
|
||||
|
||||
void
|
||||
TranslationUnit::cacheVisibleDecls(SmallVectorImpl<ValueDecl*> &&globals) const{
|
||||
auto &cached = getTUCachePimpl(LookupCachePimpl, *this).AllVisibleValues;
|
||||
static_cast<SmallVectorImpl<ValueDecl*>&>(cached) = std::move(globals);
|
||||
}
|
||||
|
||||
const SmallVectorImpl<ValueDecl *> &
|
||||
TranslationUnit::getCachedVisibleDecls() const {
|
||||
return getTUCachePimpl(LookupCachePimpl, *this).AllVisibleValues;
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// LoadedModule Implementation
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
Reference in New Issue
Block a user