Avoid a hash key generation and lookup when inserting in the LockingMechanism (#18243)

* Avoid a hash key generation and lookup when inserting in the LockingMechanism

* Added comments for CollectionsMarshal.GetValueRefOrAddDefault

* Added further comments and tests.

---------

Co-authored-by: Andy Butland <abutland73@gmail.com>
This commit is contained in:
Henrik
2025-03-26 16:55:03 +01:00
committed by GitHub
parent 028da4545e
commit 95e89f8481
3 changed files with 77 additions and 15 deletions

View File

@@ -185,10 +185,7 @@ public class ContentBuilder
{
if (string.IsNullOrWhiteSpace(name))
{
if (_cultureNames.TryGetValue(culture, out _))
{
_cultureNames.Remove(culture);
}
_cultureNames.Remove(culture);
}
else
{