rspec/rules/S6612/why-dotnet.adoc

4 lines
574 B
Plaintext

== Why is this an issue?
When using the `ConcurrentDictionary`, there are many overloads of the `GetOrAdd` and `AddOrUpdate` methods that take both a `TKey` argument and a lambda that expects a `TKey` parameter. This means that the right side of the lambda can be written using either the lambda's parameter or the method's argument. However, using the method's argument leads to the lambda capturing it, and the compiler will need to generate a class and instantiate it before the call. This means memory allocations, as well as more time spend during Garbage Collection.