Skip to content

Commit

Permalink
OptionalLinq: Add AggressiveInlining to high-level inner methods
Browse files Browse the repository at this point in the history
  • Loading branch information
andreise committed Dec 24, 2024
1 parent b74cb35 commit ef76cbe
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using System.Collections.Generic;
using System.Runtime.CompilerServices;

namespace System.Linq;

partial class OptionalLinqExtensions
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static Optional<TSource> InnerElementAtOrAbsent<TSource>(
this IEnumerable<TSource> source,
Index index)
Expand All @@ -23,6 +25,7 @@ IList<TSource> list
: source.InnerElementAtOrAbsent_IEnumerable_FromEnd(index.Value)
};

[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static Optional<TSource> InnerElementAtOrAbsent<TSource>(
this IEnumerable<TSource> source,
int index)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using System.Collections.Generic;
using System.Runtime.CompilerServices;

namespace System.Linq;

partial class OptionalLinqExtensions
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static Optional<TSource> InnerFirstOrAbsent<TSource>(
this IEnumerable<TSource> source)
=>
Expand All @@ -21,6 +23,7 @@ IList<TSource> list
source.InnerFirstOrAbsent_IEnumerable()
};

[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static Optional<TSource> InnerFirstOrAbsent<TSource>(
this IEnumerable<TSource> source,
Func<TSource, bool> predicate)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using System.Collections.Generic;
using System.Runtime.CompilerServices;

namespace System.Linq;

partial class OptionalLinqExtensions
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static Optional<TValue> InnerGetValueOrAbsent<TKey, TValue>(
this IEnumerable<KeyValuePair<TKey, TValue>> pairs,
TKey key)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using System.Collections.Generic;
using System.Runtime.CompilerServices;

namespace System.Linq;

partial class OptionalLinqExtensions
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static Optional<TSource> InnerLastOrAbsent<TSource>(
this IEnumerable<TSource> source)
=>
Expand All @@ -21,6 +23,7 @@ IList<TSource> list
source.InnerLastOrAbsent_IEnumerable()
};

[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static Optional<TSource> InnerLastOrAbsent<TSource>(
this IEnumerable<TSource> source,
Func<TSource, bool> predicate)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using System.Collections.Generic;
using System.Runtime.CompilerServices;

namespace System.Linq;

partial class OptionalLinqExtensions
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static Optional<TSource> InnerSingleOrAbsent<TSource>(
this IEnumerable<TSource> source,
Func<Exception> moreThanOneElementExceptionFactory)
Expand All @@ -22,6 +24,7 @@ IList<TSource> list
source.InnerSingleOrAbsent_IEnumerable(moreThanOneElementExceptionFactory)
};

[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static Optional<TSource> InnerSingleOrAbsent<TSource>(
this IEnumerable<TSource> source,
Func<TSource, bool> predicate,
Expand Down

0 comments on commit ef76cbe

Please sign in to comment.