Reduce allocations when setting AsyncLocal values
authorEric Eilebrecht <ericeil@microsoft.com>
Fri, 25 Sep 2015 21:03:08 +0000 (14:03 -0700)
committerEric Eilebrecht <ericeil@microsoft.com>
Sat, 26 Sep 2015 17:49:50 +0000 (10:49 -0700)
commit9bc06f7e534a1989911d795528737d767c2b408d
treec29c58eec7e533f0a1b77a15bcdae49e974ce731
parentf3f2c08269eeae29ba83df22e13e4f3a06349dcb
Reduce allocations when setting AsyncLocal values

1: Allocate a new AsyncLocal change notification list only if we need to add an item to the list.
2: Pre-size any collections we allocate, and manually copy into them to avoid IEnumerator allocations, etc.
3: Store the change notification list in an array, rather than a List, to avoid the extra List allocation.
src/mscorlib/src/System/Threading/ExecutionContext.cs