20 , LeastRecent(nullptr)
34 FCacheEntry** Entry = LookupSet.FindByHash(FLookupSet::KeyFuncsType::GetKeyHash(Key), Key);
37 MarkAsRecent( *Entry );
38 return &((*Entry)->Value);
46 FCacheEntry** Entry = LookupSet.FindByHash(FLookupSet::KeyFuncsType::GetKeyHash(Key), Key);
51 if( LookupSet.Num() == MaxNumElements )
54 checkf( LookupSet.Num() < MaxNumElements,
TEXT(
"Could not eject item from the LRU: (%d of %d), %s"), LookupSet.Num(), MaxNumElements, LeastRecent ? *LeastRecent->Key :
TEXT(
"NULL"));
57 FCacheEntry* NewEntry =
new FCacheEntry( FString(Key),
Value );
60 NewEntry->Link(MostRecent);
61 MostRecent = NewEntry;
63 if( LeastRecent ==
nullptr )
65 LeastRecent = NewEntry;
69 LookupSet.Add( NewEntry );
90 for( TSet<FCacheEntry*, FCaseSensitiveStringKeyFuncs >::TIterator It(LookupSet); It; ++It )
92 FCacheEntry* Entry = *It;
98 MostRecent = LeastRecent =
nullptr;
149 struct FCaseSensitiveStringKeyFuncs :
BaseKeyFuncs<FCacheEntry*, FString>
151 FORCEINLINE static const FString& GetSetKey(
const FCacheEntry* Entry )
173 FORCEINLINE void MarkAsRecent( FCacheEntry* Entry )
179 if( Entry == LeastRecent && LeastRecent->Prev !=
nullptr )
181 LeastRecent = LeastRecent->Prev;
185 if( Entry != MostRecent )
191 Entry->Link(MostRecent);
209 LeastRecent = LeastRecent->Prev;
219 FLookupSet LookupSet;
221 FCacheEntry* MostRecent;
223 FCacheEntry* LeastRecent;
225 int32 MaxNumElements;
#define checkSlow(expr)
Definition AssertionMacros.h:332
#define check(expr)
Definition AssertionMacros.h:314
#define checkf(expr, format,...)
Definition AssertionMacros.h:315
uint32 CityHash32(const char *s, uint32 len)
Definition CityHash.cpp:203
#define INC_MEMORY_STAT_BY(StatId, Amount)
Definition Stats.h:700
#define DEC_MEMORY_STAT_BY(StatId, Amount)
Definition Stats.h:705
#define STAT(x)
Definition Stats.h:44
#define DECLARE_MEMORY_STAT_EXTERN(CounterName, StatId, GroupId, API)
Definition Stats.h:687
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
TStringView< TCHAR > FStringView
Definition StringFwd.h:45
UE_INTRINSIC_CAST UE_REWRITE constexpr std::remove_reference_t< T > && MoveTemp(T &&Obj) noexcept
Definition UnrealTemplate.h:520
Definition FontCacheUtils.h:15
void Empty()
Definition FontCacheUtils.h:86
~FLRUStringCache()
Definition FontCacheUtils.h:24
FORCEINLINE const FVector2f * AccessItem(FStringView Key)
Definition FontCacheUtils.h:32
void Add(FStringView Key, const FVector2f &Value)
Definition FontCacheUtils.h:44
FLRUStringCache(int32 InMaxNumElements)
Definition FontCacheUtils.h:17
bool Equals(TStringView< OtherCharType > OtherView, ESearchCase::Type SearchCase=ESearchCase::CaseSensitive) const
Definition StringView.h:306
@ CaseSensitive
Definition CString.h:23
VERSECOMPILER_API bool Matches(const CTypeBase *PositiveType1, const CTypeBase *NegativeType2, const uint32_t UploadedAtFnVersion)
Determine if argument PositiveType1 is a match for parameter NegativeType2
Definition SemanticTypes.cpp:2971
Definition SetUtilities.h:23