Skip to content

Commit 61cbfc1

Browse files
committed
Simplify method calls
1 parent 764d231 commit 61cbfc1

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

Ramstack.Structures/Collections/ReadOnlyArray`1.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,7 @@ public ArrayView<T> AsView() =>
229229
/// The read-only view of the array.
230230
/// </returns>
231231
public ArrayView<T> AsView(int index) =>
232-
// ReSharper disable once ReplaceSliceWithRangeIndexer
233-
AsView().Slice(index);
232+
new(Inner ?? [], index);
234233

235234
/// <summary>
236235
/// Creates an <see cref="ArrayView{T}"/> over the current array
@@ -242,7 +241,7 @@ public ArrayView<T> AsView(int index) =>
242241
/// The read-only view of the array.
243242
/// </returns>
244243
public ArrayView<T> AsView(int index, int count) =>
245-
AsView().Slice(index, count);
244+
new(Inner ?? [], index, count);
246245

247246
/// <summary>
248247
/// Creates a new read-only memory region over the read-only array.

Ramstack.Structures/Text/StringView.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,10 @@ 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, unused: 0)
48+
public StringView(string value)
4949
{
50+
_length = value.Length;
51+
_value = value;
5052
}
5153

5254
/// <summary>

0 commit comments

Comments
 (0)