Skip to content

Commit 81487bc

Browse files
mikeashDougGregor
authored andcommitted
Change the context descriptor cache to be a SmallDenseSet instead of a TinyPtrVector to avoid duplicates.
1 parent 39280fc commit 81487bc

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

stdlib/public/runtime/MetadataLookup.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@
2828
#include "swift/Runtime/Mutex.h"
2929
#include "swift/Strings.h"
3030
#include "llvm/ADT/DenseMap.h"
31+
#include "llvm/ADT/DenseSet.h"
3132
#include "llvm/ADT/Optional.h"
3233
#include "llvm/ADT/PointerIntPair.h"
3334
#include "llvm/ADT/PointerUnion.h"
3435
#include "llvm/ADT/StringExtras.h"
35-
#include "llvm/ADT/TinyPtrVector.h"
3636
#include "Private.h"
3737
#include "CompatibilityOverride.h"
3838
#include "ImageInspection.h"
@@ -205,7 +205,7 @@ struct TypeMetadataPrivateState {
205205
ConcurrentReadableArray<TypeMetadataSection> SectionsToScan;
206206

207207
llvm::DenseMap<llvm::StringRef,
208-
llvm::TinyPtrVector<const ContextDescriptor *>>
208+
llvm::SmallDenseSet<const ContextDescriptor *, 1>>
209209
ContextDescriptorCache;
210210
size_t ConformanceDescriptorLastSectionScanned = 0;
211211
size_t TypeContextDescriptorLastSectionScanned = 0;
@@ -652,7 +652,7 @@ _scanAdditionalContextDescriptors(TypeMetadataPrivateState &T) {
652652
if (auto type = llvm::dyn_cast<TypeContextDescriptor>(ntd)) {
653653
auto identity = ParsedTypeIdentity::parse(type);
654654
auto name = identity.getABIName();
655-
T.ContextDescriptorCache[name].push_back(type);
655+
T.ContextDescriptorCache[name].insert(type);
656656
}
657657
}
658658
}
@@ -667,7 +667,7 @@ _scanAdditionalContextDescriptors(TypeMetadataPrivateState &T) {
667667
if (auto type = llvm::dyn_cast<TypeContextDescriptor>(ntd)) {
668668
auto identity = ParsedTypeIdentity::parse(type);
669669
auto name = identity.getABIName();
670-
T.ContextDescriptorCache[name].push_back(type);
670+
T.ContextDescriptorCache[name].insert(type);
671671
}
672672
}
673673
}
@@ -677,7 +677,7 @@ _scanAdditionalContextDescriptors(TypeMetadataPrivateState &T) {
677677
// Search for a ContextDescriptor in the context descriptor cache matching the
678678
// given demangle node. Returns the found node, or nullptr if no match was
679679
// found.
680-
static llvm::TinyPtrVector<const ContextDescriptor *>
680+
static llvm::SmallDenseSet<const ContextDescriptor *, 1>
681681
_findContextDescriptorInCache(TypeMetadataPrivateState &T,
682682
Demangle::NodePointer node) {
683683
if (node->getNumChildren() < 2)
@@ -731,7 +731,7 @@ _findContextDescriptor(Demangle::NodePointer node,
731731

732732
// Scan any newly loaded images for context descriptors, then try the context
733733
// descriptor cache. This must be done with the cache's lock held.
734-
llvm::TinyPtrVector<const ContextDescriptor *> cachedContexts;
734+
llvm::SmallDenseSet<const ContextDescriptor *, 1> cachedContexts;
735735
{
736736
ScopedLock guard(T.ContextDescriptorCacheLock);
737737
_scanAdditionalContextDescriptors(T);

0 commit comments

Comments
 (0)