Skip to content

Commit cb5cfc0

Browse files
committed
use Lazy instead of fancy InterlockedInitialize
1 parent 132f6b0 commit cb5cfc0

File tree

1 file changed

+2
-13
lines changed
  • src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/EditorConfig/Parsing

1 file changed

+2
-13
lines changed

src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/EditorConfig/Parsing/EditorConfigFile.cs

+2-13
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,9 @@ internal record class EditorConfigFile<T>(string? FilePath, ImmutableArray<T> Op
2020
where T : EditorConfigOption
2121
{
2222

23-
private ImmutableArray<Section> _sections;
23+
private readonly Lazy<ImmutableArray<Section>> _sections = new(() => Options.SelectAsArray(x => x.Section).Distinct());
2424

25-
public ImmutableArray<Section> Sections
26-
{
27-
get
28-
{
29-
if (_sections == default)
30-
{
31-
ImmutableInterlocked.InterlockedInitialize(ref _sections, Options.SelectAsArray(x => x.Section).Distinct());
32-
}
33-
34-
return _sections;
35-
}
36-
}
25+
public ImmutableArray<Section> Sections => _sections.Value;
3726

3827
/// <summary>
3928
/// Attempts to find a section of the editorconfig file that is an exact match for the given language.

0 commit comments

Comments
 (0)