Skip to content

Commit

Permalink
Add an IsWithin check for range
Browse files Browse the repository at this point in the history
  • Loading branch information
andreise committed Aug 20, 2023
1 parent 9fc694a commit fdf370a
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ internal static bool IsWithin(int value, int threshold)
=>
unchecked((uint)value) <= unchecked((uint)threshold);

[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static bool IsWithin(int start, int length, int threshold)
=>
(ulong)unchecked((uint)start) + unchecked((uint)length) <= unchecked((uint)threshold);

[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static int EnsurePositiveCapacity(int capacity)
=>
Expand Down

0 comments on commit fdf370a

Please sign in to comment.