Sollte ich ReadonlySpan <Arghor> als Schlüssel verwenden, in gleichzeitiger Verfassung anstelle von String, um eine bess

Post a reply

Smilies
:) :( :oops: :chelo: :roll: :wink: :muza: :sorry: :angel: :read: *x) :clever:
View more smilies

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Sollte ich ReadonlySpan <Arghor> als Schlüssel verwenden, in gleichzeitiger Verfassung anstelle von String, um eine bess

by Anonymous » 10 Apr 2025, 00:40

Der Quellcode für die gleichzeitige Verfassung erwähnt die Möglichkeit, TalternateKey zu verwenden, was eine Ref -Struktur ist.
https://github.com/dotnet/runtime/blob/ ... tionary.cs
Auch nach einiger Suche fand ich andere Beispiele. Wie hier:
https://github.com/dotnet/runtime/blob/ ... ache.cs./p>

Code: Select all

#if NET9_0_OR_GREATER
private readonly ConcurrentDictionary.AlternateLookup _stringAltLookup;

public CoherentState()
{
_stringAltLookup = _stringEntries.GetAlternateLookup();
}
#endif
//...
#if NET9_0_OR_GREATER
internal bool TryGetValue(ReadOnlySpan key, [NotNullWhen(true)] out CacheEntry? entry)
=> _stringAltLookup.TryGetValue(key, out entry);
#endif

#if NET9_0_OR_GREATER
private readonly ConcurrentDictionary.AlternateLookup _stringAltLookup;

public CoherentState()
{
_stringAltLookup = _stringEntries.GetAlternateLookup();
}
#endif
Sollte ich ReadOnlySpan als Schlüssel verwenden, in gleichzeitiger Verfassung anstelle von String für eine bessere Leistung?

Top