-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #48356 from sharwell/perf-1224834
Implement low-hanging performance improvements from feedback investigation
- Loading branch information
Showing
39 changed files
with
263 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/Compilers/Core/CodeAnalysisTest/InternalUtilities/ConcurrentDictionaryExtensionsTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System; | ||
using System.Collections.Concurrent; | ||
using Roslyn.Utilities; | ||
using Xunit; | ||
|
||
namespace Microsoft.CodeAnalysis.UnitTests.InternalUtilities | ||
{ | ||
public class ConcurrentDictionaryExtensionsTests | ||
{ | ||
[Fact] | ||
public void TestAdd() | ||
{ | ||
var dictionary = new ConcurrentDictionary<int, int>(); | ||
dictionary.Add(0, 0); | ||
Assert.Equal(0, dictionary[0]); | ||
|
||
Assert.Throws<ArgumentException>(() => dictionary.Add(0, 0)); | ||
} | ||
|
||
[Fact] | ||
public void TestGetOrAdd() | ||
{ | ||
var first = new object(); | ||
var second = new object(); | ||
|
||
var dictionary = new ConcurrentDictionary<int, object>(); | ||
Assert.Same(first, dictionary.GetOrAdd(0, static (key, arg) => arg, first)); | ||
Assert.Same(first, dictionary[0]); | ||
Assert.Single(dictionary); | ||
Assert.Same(first, dictionary.GetOrAdd(0, static (key, arg) => arg, second)); | ||
Assert.Same(first, dictionary[0]); | ||
Assert.Single(dictionary); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.