From 045b9e346c2815de44813e2f78bf46458d0a9fc6 Mon Sep 17 00:00:00 2001 From: Andrei Sergeev Date: Thu, 24 Aug 2023 02:58:45 +0400 Subject: [PATCH] Add AggressiveInlining to internal factories --- .../FlatArray.T/FlatArray.Factory.Explicit.From.Array.cs | 2 ++ .../FlatArray.T/FlatArray.Factory.Explicit.From.FlatArray.cs | 5 ++++- .../FlatArray.Factory.Explicit.From.ImmutableArray.cs | 2 ++ .../FlatArray.T/FlatArray.Factory.Explicit.From.List.cs | 2 ++ 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/flatcollections-array/FlatArray/FlatArray.T/FlatArray.Factory.Explicit.From.Array.cs b/src/flatcollections-array/FlatArray/FlatArray.T/FlatArray.Factory.Explicit.From.Array.cs index b27be4cd..d98b8334 100644 --- a/src/flatcollections-array/FlatArray/FlatArray.T/FlatArray.Factory.Explicit.From.Array.cs +++ b/src/flatcollections-array/FlatArray/FlatArray.T/FlatArray.Factory.Explicit.From.Array.cs @@ -1,4 +1,5 @@ using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; namespace System; @@ -13,6 +14,7 @@ internal static FlatArray From([AllowNull] T[] source, int start, int length) => InternalFromArrayChecked(source, start, length); + [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static FlatArray InternalFromArrayChecked([AllowNull] T[] source, int start, int length) { var sourceLength = source?.Length ?? default; diff --git a/src/flatcollections-array/FlatArray/FlatArray.T/FlatArray.Factory.Explicit.From.FlatArray.cs b/src/flatcollections-array/FlatArray/FlatArray.T/FlatArray.Factory.Explicit.From.FlatArray.cs index 2aabe9c9..bb3b195a 100644 --- a/src/flatcollections-array/FlatArray/FlatArray.T/FlatArray.Factory.Explicit.From.FlatArray.cs +++ b/src/flatcollections-array/FlatArray/FlatArray.T/FlatArray.Factory.Explicit.From.FlatArray.cs @@ -1,4 +1,6 @@ -namespace System; +using System.Runtime.CompilerServices; + +namespace System; partial struct FlatArray { @@ -20,6 +22,7 @@ internal static FlatArray From(FlatArray? source, int start, int length) => InternalFromFlatArrayChecked(source.GetValueOrDefault(), start, length); + [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static FlatArray InternalFromFlatArrayChecked(FlatArray source, int start, int length) { if (InnerAllocHelper.IsSegmentWithinLength(start, length, source.length) is not true) diff --git a/src/flatcollections-array/FlatArray/FlatArray.T/FlatArray.Factory.Explicit.From.ImmutableArray.cs b/src/flatcollections-array/FlatArray/FlatArray.T/FlatArray.Factory.Explicit.From.ImmutableArray.cs index edfa7d78..6528c0f0 100644 --- a/src/flatcollections-array/FlatArray/FlatArray.T/FlatArray.Factory.Explicit.From.ImmutableArray.cs +++ b/src/flatcollections-array/FlatArray/FlatArray.T/FlatArray.Factory.Explicit.From.ImmutableArray.cs @@ -1,4 +1,5 @@ using System.Collections.Immutable; +using System.Runtime.CompilerServices; namespace System; @@ -22,6 +23,7 @@ internal static FlatArray From(ImmutableArray? source, int start, int leng => InternalFromImmutableArrayChecked(source.GetValueOrDefault(), start, length); + [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static FlatArray InternalFromImmutableArrayChecked(ImmutableArray source, int start, int length) { var sourceLength = source.IsDefault ? default : source.Length; diff --git a/src/flatcollections-array/FlatArray/FlatArray.T/FlatArray.Factory.Explicit.From.List.cs b/src/flatcollections-array/FlatArray/FlatArray.T/FlatArray.Factory.Explicit.From.List.cs index 4907e36b..2da540b2 100644 --- a/src/flatcollections-array/FlatArray/FlatArray.T/FlatArray.Factory.Explicit.From.List.cs +++ b/src/flatcollections-array/FlatArray/FlatArray.T/FlatArray.Factory.Explicit.From.List.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; namespace System; @@ -14,6 +15,7 @@ internal static FlatArray From([AllowNull] List source, int start, int len => InternalFromListChecked(source, start, length); + [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static FlatArray InternalFromListChecked([AllowNull] List source, int start, int length) { var sourceLength = source?.Count ?? default;