TryAddWithoutValidation for multiple values could be more efficient #64049
Labels
area-System.Net.Http
enhancement
Product code improvement that does NOT require public API changes/additions
help wanted
[up-for-grabs] Good issue for external contributors
in-pr
There is an active PR which will close this issue when it is merged
tenet-performance
Performance related issue
Milestone
The method takes an
IEnumerable<string>
. Things we could improve:IList<string>
or some other type to avoid boxing the enumeratorList
resizes if we already know the final sizeFor example
Will currently allocate the enumerator, a
List<string>
of size 2, and aList<string>
of size 4.We can reduce that down to allocating a single
List<string>
of size 3.An example of how this can be achieved:
https://gist.github.com/MihaZupan/800df7a324a66a8e814c3ec91f3d39b0
The text was updated successfully, but these errors were encountered: