Skip to content

Commit f5e8e9d

Browse files
committed
Rename dummy parameter to unused
1 parent 65e0288 commit f5e8e9d

2 files changed

Lines changed: 33 additions & 21 deletions

File tree

Ramstack.Structures/Collections/ArrayView`1.cs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,17 +101,23 @@ public ArrayView(T[] array, int index, int length)
101101
/// Initializes a new instance of the <see cref="ArrayView{T}"/> structure that creates
102102
/// a view for the specified range of the elements in the specified array.
103103
/// </summary>
104+
/// <remarks>
105+
/// This constructor is intentionally minimal and skips all argument validations,
106+
/// as the caller is responsible for ensuring correctness (e.g.,
107+
/// <paramref name="array"/> is non-null, <paramref name="index"/> and
108+
/// <paramref name="length"/> are within bounds).
109+
/// </remarks>
104110
/// <param name="array">The array to wrap.</param>
105111
/// <param name="index">The zero-based index of the first element in the range.</param>
106112
/// <param name="length">The number of elements in the range.</param>
107-
/// <param name="dummy">The dummy parameter.</param>
113+
/// <param name="unused">Unused parameter, exists solely to disambiguate overloads.</param>
108114
[MethodImpl(MethodImplOptions.AggressiveInlining)]
109-
private ArrayView(T[] array, int index, int length, int dummy)
115+
private ArrayView(T[] array, int index, int length, int unused)
110116
{
111117
_index = index;
112118
_count = length;
113119
_array = array;
114-
_ = dummy;
120+
_ = unused;
115121
}
116122

117123
/// <inheritdoc cref="IEnumerable{T}.GetEnumerator"/>
@@ -132,7 +138,7 @@ public ArrayView<T> Slice(int index)
132138
if ((uint)index > (uint)_count)
133139
ThrowHelper.ThrowArgumentOutOfRangeException();
134140

135-
return new ArrayView<T>(_array!, _index + index, _count - index, dummy: 0);
141+
return new ArrayView<T>(_array!, _index + index, _count - index, unused: 0);
136142
}
137143

138144
/// <summary>
@@ -157,7 +163,7 @@ public ArrayView<T> Slice(int index, int count)
157163
ThrowHelper.ThrowArgumentOutOfRangeException();
158164
}
159165

160-
return new ArrayView<T>(_array!, _index + index, count, dummy: 0);
166+
return new ArrayView<T>(_array!, _index + index, count, unused: 0);
161167
}
162168

163169
/// <summary>
@@ -316,7 +322,7 @@ ref array.GetRawArrayData(view._index),
316322
/// A <see cref="ArrayView{T}"/> representation of the array segment.
317323
/// </returns>
318324
public static implicit operator ArrayView<T>(ArraySegment<T> segment) =>
319-
new(segment.Array!, segment.Offset, segment.Count, dummy: 0);
325+
new(segment.Array!, segment.Offset, segment.Count, unused: 0);
320326

321327
/// <summary>
322328
/// Returns a string representation of the current instance's state,

Ramstack.Structures/Text/StringView.cs

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public char this[int index]
4545
/// </summary>
4646
/// <param name="value">The string to wrap.</param>
4747
[MethodImpl(MethodImplOptions.AggressiveInlining)]
48-
public StringView(string value) : this(value, 0, value.Length, dummy: 0)
48+
public StringView(string value) : this(value, 0, value.Length, unused: 0)
4949
{
5050
}
5151

@@ -96,17 +96,23 @@ public StringView(string value, int index, int length)
9696
/// Initializes a new instance of the <see cref="StringView"/> structure that creates
9797
/// a view for the specified range of the characters in the specified string.
9898
/// </summary>
99+
/// <remarks>
100+
/// This constructor is intentionally minimal and skips all argument validations,
101+
/// as the caller is responsible for ensuring correctness (e.g.,
102+
/// <paramref name="value"/> is non-null, <paramref name="index"/> and
103+
/// <paramref name="length"/> are within bounds).
104+
/// </remarks>
99105
/// <param name="value">The string to wrap.</param>
100106
/// <param name="index">The zero-based index of the first character in the range.</param>
101107
/// <param name="length">The number of characters in the range.</param>
102-
/// <param name="dummy">The dummy parameter.</param>
108+
/// <param name="unused">Unused parameter, exists solely to disambiguate overloads.</param>
103109
[MethodImpl(MethodImplOptions.AggressiveInlining)]
104-
private StringView(string value, int index, int length, int dummy)
110+
private StringView(string value, int index, int length, int unused)
105111
{
106112
_index = index;
107113
_length = length;
108114
_value = value;
109-
_ = dummy;
115+
_ = unused;
110116
}
111117

112118
/// <inheritdoc cref="IEnumerable{T}.GetEnumerator"/>
@@ -156,7 +162,7 @@ public StringView Slice(int start)
156162
if ((uint)start > (uint)_length)
157163
ThrowHelper.ThrowArgumentOutOfRangeException();
158164

159-
return new StringView(_value!, _index + start, _length - start, dummy: 0);
165+
return new StringView(_value!, _index + start, _length - start, unused: 0);
160166
}
161167

162168
/// <summary>
@@ -182,7 +188,7 @@ public StringView Slice(int start, int length)
182188
ThrowHelper.ThrowArgumentOutOfRangeException();
183189
}
184190

185-
return new StringView(_value!, _index + start, length, dummy: 0);
191+
return new StringView(_value!, _index + start, length, unused: 0);
186192
}
187193

188194
/// <summary>
@@ -256,7 +262,7 @@ public StringView TrimStart()
256262
if (!char.IsWhiteSpace(value.GetRawStringData(start)))
257263
break;
258264

259-
return new StringView(value!, start, final - start, dummy: 0);
265+
return new StringView(value!, start, final - start, unused: 0);
260266
}
261267

262268
/// <summary>
@@ -277,7 +283,7 @@ public StringView TrimStart(char trimChar)
277283
if (value.GetRawStringData(start) != trimChar)
278284
break;
279285

280-
return new StringView(value!, start, final - start, dummy: 0);
286+
return new StringView(value!, start, final - start, unused: 0);
281287
}
282288

283289
/// <summary>
@@ -328,7 +334,7 @@ public StringView TrimStart(ReadOnlySpan<char> trimChars)
328334
}
329335
}
330336

331-
return new StringView(value!, start, final - start, dummy: 0);
337+
return new StringView(value!, start, final - start, unused: 0);
332338
}
333339

334340
/// <summary>
@@ -348,7 +354,7 @@ public StringView TrimEnd()
348354
if (!char.IsWhiteSpace(value.GetRawStringData(final)))
349355
break;
350356

351-
return new StringView(value!, start, final + 1 - start, dummy: 0);
357+
return new StringView(value!, start, final + 1 - start, unused: 0);
352358
}
353359

354360
/// <summary>
@@ -369,7 +375,7 @@ public StringView TrimEnd(char trimChar)
369375
if (value.GetRawStringData(final) != trimChar)
370376
break;
371377

372-
return new StringView(value!, start, final + 1 - start, dummy: 0);
378+
return new StringView(value!, start, final + 1 - start, unused: 0);
373379
}
374380

375381
/// <summary>
@@ -420,7 +426,7 @@ public StringView TrimEnd(ReadOnlySpan<char> trimChars)
420426
}
421427
}
422428

423-
return new StringView(value!, start, final + 1 - start, dummy: 0);
429+
return new StringView(value!, start, final + 1 - start, unused: 0);
424430
}
425431

426432
/// <summary>
@@ -446,7 +452,7 @@ public StringView Trim()
446452
break;
447453
}
448454

449-
return new StringView(value!, start, final + 1 - start, dummy: 0);
455+
return new StringView(value!, start, final + 1 - start, unused: 0);
450456
}
451457

452458
/// <summary>
@@ -473,7 +479,7 @@ public StringView Trim(char trimChar)
473479
break;
474480
}
475481

476-
return new StringView(value!, start, final + 1 - start, dummy: 0);
482+
return new StringView(value!, start, final + 1 - start, unused: 0);
477483
}
478484

479485
/// <summary>
@@ -534,7 +540,7 @@ public StringView Trim(ReadOnlySpan<char> trimChars)
534540
}
535541
}
536542

537-
return new StringView(value!, start, final + 1 - start, dummy: 0);
543+
return new StringView(value!, start, final + 1 - start, unused: 0);
538544
}
539545

540546
/// <summary>

0 commit comments

Comments
 (0)