File tree Expand file tree Collapse file tree 4 files changed +13
-15
lines changed Expand file tree Collapse file tree 4 files changed +13
-15
lines changed Original file line number Diff line number Diff line change @@ -943,7 +943,7 @@ class ASTContext final {
943
943
}
944
944
945
945
// / Logically, there is a separate cache for each SourceFile.
946
- llvm::SmallVectorImpl< Type> &getDefaultTypeRequestCache (SourceFile *);
946
+ Type &getDefaultTypeRequestCache (SourceFile *, KnownProtocolKind );
947
947
948
948
private:
949
949
friend Decl;
Original file line number Diff line number Diff line change @@ -361,7 +361,7 @@ class DefaultTypeRequest
361
361
static bool getPerformLocalLookup (KnownProtocolKind);
362
362
TypeChecker &getTypeChecker () const ;
363
363
SourceFile *getSourceFile () const ;
364
- llvm::SmallVectorImpl< Type> &getCache () const ;
364
+ Type &getCache () const ;
365
365
bool isDependencyMissing (Type result) const ;
366
366
};
367
367
Original file line number Diff line number Diff line change @@ -293,7 +293,7 @@ FOR_KNOWN_FOUNDATION_TYPES(CACHE_FOUNDATION_DECL)
293
293
// / Caches of default types for DefaultTypeRequest.
294
294
// / Used to be instance variables in the TypeChecker.
295
295
// / There is a logically separate cache for each SourceFile.
296
- llvm::DenseMap<SourceFile *, llvm::SmallVector <Type, NumKnownProtocols>>
296
+ llvm::DenseMap<SourceFile *, std::array <Type, NumKnownProtocols>>
297
297
DefaultTypeRequestCaches;
298
298
299
299
// / Structure that captures data that is segregated into different
@@ -5080,7 +5080,7 @@ LayoutConstraint LayoutConstraint::getLayoutConstraint(LayoutConstraintKind Kind
5080
5080
return LayoutConstraint (New);
5081
5081
}
5082
5082
5083
- llvm::SmallVectorImpl< Type> &
5084
- ASTContext::getDefaultTypeRequestCache (SourceFile *SF) {
5085
- return getImpl ().DefaultTypeRequestCaches [SF];
5083
+ Type &
5084
+ ASTContext::getDefaultTypeRequestCache (SourceFile *SF, KnownProtocolKind kind ) {
5085
+ return getImpl ().DefaultTypeRequestCaches [SF][ size_t (kind)] ;
5086
5086
}
Original file line number Diff line number Diff line change @@ -456,20 +456,19 @@ SourceFile *DefaultTypeRequest::getSourceFile() const {
456
456
return getDeclContext ()->getParentSourceFile ();
457
457
}
458
458
459
- llvm::SmallVectorImpl< Type> &DefaultTypeRequest::getCache () const {
459
+ Type &DefaultTypeRequest::getCache () const {
460
460
return getDeclContext ()->getASTContext ().getDefaultTypeRequestCache (
461
- getSourceFile ());
461
+ getSourceFile (), getKnownProtocolKind () );
462
462
}
463
463
464
464
Optional<Type> DefaultTypeRequest::getCachedResult () const {
465
- auto const &cache = getCache ();
466
- Type result = cache[size_t (getKnownProtocolKind ())];
467
- if (!result)
465
+ auto const &cachedType = getCache ();
466
+ if (!cachedType)
468
467
return None;
469
- assert (!isDependencyMissing (result ) &&
468
+ assert (!isDependencyMissing (cachedType ) &&
470
469
" Since the cache is now cached by SourceFile, the dependency should "
471
470
" have been recorded when it was looked up." );
472
- return result ;
471
+ return cachedType ;
473
472
}
474
473
475
474
bool DefaultTypeRequest::isDependencyMissing (Type result) const {
@@ -482,8 +481,7 @@ bool DefaultTypeRequest::isDependencyMissing(Type result) const {
482
481
}
483
482
484
483
void DefaultTypeRequest::cacheResult (Type value) const {
485
- auto &cache = getCache ();
486
- cache[size_t (getKnownProtocolKind ())] = value;
484
+ getCache () = value;
487
485
}
488
486
489
487
const char *
You can’t perform that action at this time.
0 commit comments