Skip to content

Commit

Permalink
Add AggressiveInlining to internal factories
Browse files Browse the repository at this point in the history
  • Loading branch information
andreise committed Aug 23, 2023
1 parent e6d5c93 commit 045b9e3
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;

namespace System;

Expand All @@ -13,6 +14,7 @@ internal static FlatArray<T> From([AllowNull] T[] source, int start, int length)
=>
InternalFromArrayChecked(source, start, length);

[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static FlatArray<T> InternalFromArrayChecked([AllowNull] T[] source, int start, int length)
{
var sourceLength = source?.Length ?? default;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace System;
using System.Runtime.CompilerServices;

namespace System;

partial struct FlatArray<T>
{
Expand All @@ -20,6 +22,7 @@ internal static FlatArray<T> From(FlatArray<T>? source, int start, int length)
=>
InternalFromFlatArrayChecked(source.GetValueOrDefault(), start, length);

[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static FlatArray<T> InternalFromFlatArrayChecked(FlatArray<T> source, int start, int length)
{
if (InnerAllocHelper.IsSegmentWithinLength(start, length, source.length) is not true)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Immutable;
using System.Runtime.CompilerServices;

namespace System;

Expand All @@ -22,6 +23,7 @@ internal static FlatArray<T> From(ImmutableArray<T>? source, int start, int leng
=>
InternalFromImmutableArrayChecked(source.GetValueOrDefault(), start, length);

[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static FlatArray<T> InternalFromImmutableArrayChecked(ImmutableArray<T> source, int start, int length)
{
var sourceLength = source.IsDefault ? default : source.Length;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;

namespace System;

Expand All @@ -14,6 +15,7 @@ internal static FlatArray<T> From([AllowNull] List<T> source, int start, int len
=>
InternalFromListChecked(source, start, length);

[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static FlatArray<T> InternalFromListChecked([AllowNull] List<T> source, int start, int length)
{
var sourceLength = source?.Count ?? default;
Expand Down

0 comments on commit 045b9e3

Please sign in to comment.