I Knew the Count and Let the List Guess Twenty Times
DEV Community
I Knew the Count and Let the List Guess Twenty Times
A plain Add loop filling a List<long> of two million items reallocated its backing array twenty times and allocated twice the memory it needed. Here's the measured cost, the one-line fix, and which LINQ patterns already pre-size for you.
0 comments
No comments yet.