Skip to content

Commit

Permalink
Remove GetOrAdd extension method
Browse files Browse the repository at this point in the history
  • Loading branch information
gustavopsantos committed Feb 25, 2025
1 parent 8c8947d commit 7988fd1
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 24 deletions.
8 changes: 7 additions & 1 deletion Assets/Reflex/Caching/TypeConstructionInfoCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ internal static class TypeConstructionInfoCache

internal static TypeConstructionInfo Get(Type type)
{
return _dictionary.GetOrAdd(type, Generate);
if (!_dictionary.TryGetValue(type, out var info))
{
info = Generate(type);
_dictionary.Add(type, info);
}

return info;
}

private static TypeConstructionInfo Generate(Type type)
Expand Down
7 changes: 6 additions & 1 deletion Assets/Reflex/Core/ContainerBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ public Container Build()

foreach (var contract in binding.Contracts)
{
var resolvers = resolversByContract.GetOrAdd(contract, _ => new List<IResolver>());
if (!resolversByContract.TryGetValue(contract, out var resolvers))
{
resolvers = new List<IResolver>();
resolversByContract.Add(contract, resolvers);
}

resolvers.Add(binding.Resolver);
}
}
Expand Down
19 changes: 0 additions & 19 deletions Assets/Reflex/Extensions/DictionaryExtensions.cs

This file was deleted.

3 changes: 0 additions & 3 deletions Assets/Reflex/Extensions/DictionaryExtensions.cs.meta

This file was deleted.

0 comments on commit 7988fd1

Please sign in to comment.