Reduce number of TLS accesses in AllocFreeConcurrentStack<T>

AllocFreeConcurrentStack<T>'s TryAdd and TryTake methods both access a [ThreadStatic] field multiple times in any one invocation.  These repeated TLS accesses might not be optimized away, in which case the overhead is higher than necessary.  This PR caches the [ThreadStatic] into a local which is then what's accessed repeatedly.  In a microbenchmark of enumerating very small collections (e.g. an ImmutableList<int> containing one item), this yielded upwards of a 10% throughput improvement on my machine.
Oh, good point about implicitly importing System. Disregard my comment then.

On Wed, Nov 12, 2014, 7:33 PM Stephen Toub <notifications@github.com> wrote:

> In
> src/System.Collections.Immutable/src/System/Collections/Immutable/AllocFreeConcurrentStack.cs:
>
> > @@ -1,11 +1,8 @@
> >  // Copyright (c) Microsoft. All rights reserved.
> >  // Licensed under the MIT license. See LICENSE file in the project root for full license information.
> >
> > -using System;
>
> Thanks, @AArnott <https://github.com/AArnott>. While I understand that
> sentiment in general, I don't think it applies here. This code is all in
> the "System.Collections.Immutable" namespace, which means the compiler is
> already importing the System namespace, even without the "using System;"
> line. As for "using System.Linq;", while in general it's productive to have
> it imported, I think it's good for a dev to have to pause and think for a
> moment before using LINQ in a class whose name includes the phrase
> "AllocFree" ;) And "using System.Text;", well, I don't have a strong
> opinion about that one. All that said, let me know if you still feel
> strongly about these, and I can put them back if you'd prefer it.
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/dotnet/corefx/pull/59/files#r20270774>.
>