Skip to content

Commit dae4f84

Browse files
author
DaZombieKiller
committed
Add AggressiveInlining to Length property on RefEnumerable
1 parent 86625a0 commit dae4f84

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

Microsoft.Toolkit.HighPerformance/Enumerables/ReadOnlyRefEnumerable{T}.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#endif
1111
using Microsoft.Toolkit.HighPerformance.Helpers.Internals;
1212
using Microsoft.Toolkit.HighPerformance.Memory.Internals;
13-
1413
#if !SPAN_RUNTIME_SUPPORT
1514
using RuntimeHelpers = Microsoft.Toolkit.HighPerformance.Helpers.Internals.RuntimeHelpers;
1615
#endif
@@ -126,6 +125,7 @@ internal ReadOnlyRefEnumerable(object? instance, IntPtr offset, int length, int
126125
/// </summary>
127126
public int Length
128127
{
128+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
129129
#if SPAN_RUNTIME_SUPPORT
130130
get => this.span.Length;
131131
#else
@@ -157,6 +157,7 @@ public ref readonly T this[int index]
157157
#endif
158158
nint offset = (nint)(uint)index * (nint)(uint)this.step;
159159
ref T ri = ref Unsafe.Add(ref r0, offset);
160+
160161
return ref ri;
161162
}
162163
}

Microsoft.Toolkit.HighPerformance/Enumerables/RefEnumerable{T}.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#endif
1111
using Microsoft.Toolkit.HighPerformance.Helpers.Internals;
1212
using Microsoft.Toolkit.HighPerformance.Memory.Internals;
13-
1413
#if !SPAN_RUNTIME_SUPPORT
1514
using RuntimeHelpers = Microsoft.Toolkit.HighPerformance.Helpers.Internals.RuntimeHelpers;
1615
#endif
@@ -109,6 +108,7 @@ internal RefEnumerable(object? instance, IntPtr offset, int length, int step)
109108
/// </summary>
110109
public int Length
111110
{
111+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
112112
#if SPAN_RUNTIME_SUPPORT
113113
get => this.Span.Length;
114114
#else
@@ -140,6 +140,7 @@ public ref T this[int index]
140140
#endif
141141
nint offset = (nint)(uint)index * (nint)(uint)this.Step;
142142
ref T ri = ref Unsafe.Add(ref r0, offset);
143+
143144
return ref ri;
144145
}
145146
}

0 commit comments

Comments
 (0)