Skip to content

Commit 06c797e

Browse files
authored
Remove the UseCache property and old benchmark (#12962)
I _SWEAR_ I pushed a commit that did this before I merged my other PR, but either GitHub was having issues, or I was in a fugue state
2 parents 599013a + e5ff730 commit 06c797e

2 files changed

Lines changed: 3 additions & 25 deletions

File tree

src/Razor/benchmarks/Microsoft.AspNetCore.Razor.Microbenchmarks/Formatting/DocumentFormattingBenchmark.cs

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ public void Setup()
9292
CSharpSyntaxFormattingOptions = RazorCSharpSyntaxFormattingOptions.Default,
9393
};
9494

95-
IndentCache.UseCache = true;
9695
var changeCount = FormatDocumentCore();
9796
if (changeCount == 0)
9897
{
@@ -103,29 +102,12 @@ public void Setup()
103102
[GlobalCleanup]
104103
public void Cleanup()
105104
{
106-
IndentCache.UseCache = true;
107105
_workspace?.Dispose();
108106
}
109107

110-
[Benchmark(Baseline = true, Description = "100x full document formatting of Razor file (indent cache on)")]
108+
[Benchmark(Baseline = true, Description = "100x full document formatting of Razor file")]
111109
public int FormatDocument()
112110
{
113-
IndentCache.UseCache = true;
114-
115-
var totalChangeCount = 0;
116-
for (var i = 0; i < FormatOperationCount; i++)
117-
{
118-
totalChangeCount += FormatDocumentCore();
119-
}
120-
121-
return totalChangeCount;
122-
}
123-
124-
[Benchmark(Description = "100x full document formatting of Razor file (indent cache off)")]
125-
public int FormatDocumentWithoutIndentCache()
126-
{
127-
IndentCache.UseCache = false;
128-
129111
var totalChangeCount = 0;
130112
for (var i = 0; i < FormatOperationCount; i++)
131113
{

src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Formatting/IndentCache.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@ namespace Microsoft.CodeAnalysis.Razor.Formatting;
1010

1111
internal static class IndentCache
1212
{
13-
// Exists only so benchmarks can compare cached and uncached formatting runs.
14-
// Production code should leave this enabled.
15-
public static bool UseCache { get; set; } = true;
16-
1713
// Copied from the compilers IndentCache
1814
internal const int MaxTabCount = 64;
1915
internal const int MaxSpaceCount = 128;
@@ -59,7 +55,7 @@ public static string GetIndentString(int size, bool insertSpaces, int tabSize)
5955

6056
private static string GetSingleCharacterString(int length, char character, string?[] cache)
6157
{
62-
if (length >= cache.Length || !UseCache)
58+
if (length >= cache.Length)
6359
{
6460
return new string(character, length);
6561
}
@@ -77,7 +73,7 @@ private static string GetSingleCharacterString(int length, char character, strin
7773

7874
private static string GetMixedString(int tabCount, int spaceCount)
7975
{
80-
if (tabCount > MaxTabCount || spaceCount > MaxSpaceCountInMixedString || !UseCache)
76+
if (tabCount > MaxTabCount || spaceCount > MaxSpaceCountInMixedString)
8177
{
8278
return CreateMixedString(tabCount, spaceCount);
8379
}

0 commit comments

Comments
 (0)