Skip to content

Commit edabdc6

Browse files
committed
Rename some things
1 parent 4816433 commit edabdc6

File tree

1 file changed

+28
-28
lines changed

1 file changed

+28
-28
lines changed

src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/TextDifferencing/SourceTextDiffer.TextSpanDiffer.cs

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ internal partial class SourceTextDiffer
1111
{
1212
private abstract class TextSpanDiffer : SourceTextDiffer
1313
{
14-
private readonly ImmutableArray<TextSpan> _oldLines = [];
15-
private readonly ImmutableArray<TextSpan> _newLines = [];
14+
private readonly ImmutableArray<TextSpan> _oldSpans = [];
15+
private readonly ImmutableArray<TextSpan> _newSpans = [];
1616

17-
private char[] _oldLineBuffer;
18-
private char[] _newLineBuffer;
17+
private char[] _oldBuffer;
18+
private char[] _newBuffer;
1919
private char[] _appendBuffer;
2020

2121
protected override int OldSourceLength { get; }
@@ -24,44 +24,44 @@ private abstract class TextSpanDiffer : SourceTextDiffer
2424
public TextSpanDiffer(SourceText oldText, SourceText newText)
2525
: base(oldText, newText)
2626
{
27-
_oldLineBuffer = RentArray(1024);
28-
_newLineBuffer = RentArray(1024);
27+
_oldBuffer = RentArray(1024);
28+
_newBuffer = RentArray(1024);
2929
_appendBuffer = RentArray(1024);
3030

3131
if (oldText.Length > 0)
3232
{
33-
_oldLines = Tokenize(oldText);
33+
_oldSpans = Tokenize(oldText);
3434
}
3535

3636
if (newText.Length > 0)
3737
{
38-
_newLines = Tokenize(newText);
38+
_newSpans = Tokenize(newText);
3939
}
4040

41-
OldSourceLength = _oldLines.Length;
42-
NewSourceLength = _newLines.Length;
41+
OldSourceLength = _oldSpans.Length;
42+
NewSourceLength = _newSpans.Length;
4343
}
4444

4545
protected abstract ImmutableArray<TextSpan> Tokenize(SourceText text);
4646

4747
public override void Dispose()
4848
{
49-
ReturnArray(_oldLineBuffer);
50-
ReturnArray(_newLineBuffer);
49+
ReturnArray(_oldBuffer);
50+
ReturnArray(_newBuffer);
5151
ReturnArray(_appendBuffer);
5252
}
5353

5454
protected override bool SourceEqual(int oldSourceIndex, int newSourceIndex)
5555
{
56-
var oldLine = _oldLines[oldSourceIndex];
57-
var newLine = _newLines[newSourceIndex];
56+
var oldSpan = _oldSpans[oldSourceIndex];
57+
var newSpan = _newSpans[newSourceIndex];
5858

59-
if (oldLine.Length != newLine.Length)
59+
if (oldSpan.Length != newSpan.Length)
6060
{
6161
return false;
6262
}
6363

64-
var length = oldLine.Length;
64+
var length = oldSpan.Length;
6565

6666
// Simple case: Both lines are empty.
6767
if (length == 0)
@@ -72,11 +72,11 @@ protected override bool SourceEqual(int oldSourceIndex, int newSourceIndex)
7272
// Copy the text into char arrays for comparison. Note: To avoid allocation,
7373
// we try to reuse the same char buffers and only grow them when a longer
7474
// line is encountered.
75-
var oldChars = EnsureBuffer(ref _oldLineBuffer, length);
76-
var newChars = EnsureBuffer(ref _newLineBuffer, length);
75+
var oldChars = EnsureBuffer(ref _oldBuffer, length);
76+
var newChars = EnsureBuffer(ref _newBuffer, length);
7777

78-
OldText.CopyTo(oldLine.Start, oldChars, 0, length);
79-
NewText.CopyTo(newLine.Start, newChars, 0, length);
78+
OldText.CopyTo(oldSpan.Start, oldChars, 0, length);
79+
NewText.CopyTo(newSpan.Start, newChars, 0, length);
8080

8181
for (var i = 0; i < length; i++)
8282
{
@@ -90,7 +90,7 @@ protected override bool SourceEqual(int oldSourceIndex, int newSourceIndex)
9090
}
9191

9292
protected override int GetEditPosition(DiffEdit edit)
93-
=> _oldLines[edit.Position].Start;
93+
=> _oldSpans[edit.Position].Start;
9494

9595
protected override int AppendEdit(DiffEdit edit, StringBuilder builder)
9696
{
@@ -101,21 +101,21 @@ protected override int AppendEdit(DiffEdit edit, StringBuilder builder)
101101

102102
for (var i = 0; i < edit.Length; i++)
103103
{
104-
var newLine = _newLines[newTextPosition + i];
104+
var newSpan = _newSpans[newTextPosition + i];
105105

106-
if (newLine.Length > 0)
106+
if (newSpan.Length > 0)
107107
{
108-
var buffer = EnsureBuffer(ref _appendBuffer, newLine.Length);
109-
NewText.CopyTo(newLine.Start, buffer, 0, newLine.Length);
108+
var buffer = EnsureBuffer(ref _appendBuffer, newSpan.Length);
109+
NewText.CopyTo(newSpan.Start, buffer, 0, newSpan.Length);
110110

111-
builder.Append(buffer, 0, newLine.Length);
111+
builder.Append(buffer, 0, newSpan.Length);
112112
}
113113
}
114114

115-
return _oldLines[edit.Position].Start;
115+
return _oldSpans[edit.Position].Start;
116116
}
117117

118-
return _oldLines[edit.Position + edit.Length - 1].End;
118+
return _oldSpans[edit.Position + edit.Length - 1].End;
119119
}
120120
}
121121
}

0 commit comments

Comments
 (0)