Pre-initializing list/dictionaries gives speed improvement
Recently i found out that you gain around 50% speed improvement when adding items to a list/ dictionary if the list/dictionary was initialized before adding the item to it. This is very helpful in the cases where you know how many items the list is going to contain ( or at least approximately )
var list = new List<T>(1000);
Written by Nikola Sivkov
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#C
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#