Skip to content

Commit

Permalink
Use optimized GetOffset in Range GetOffsetAndLength (dotnet#87317)
Browse files Browse the repository at this point in the history
  • Loading branch information
yesmey authored Jul 17, 2023
1 parent 243650a commit 4ebb3ea
Showing 1 changed file with 2 additions and 13 deletions.
15 changes: 2 additions & 13 deletions src/libraries/System.Private.CoreLib/src/System/Range.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,19 +115,8 @@ public override string ToString()
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public (int Offset, int Length) GetOffsetAndLength(int length)
{
int start;
Index startIndex = Start;
if (startIndex.IsFromEnd)
start = length - startIndex.Value;
else
start = startIndex.Value;

int end;
Index endIndex = End;
if (endIndex.IsFromEnd)
end = length - endIndex.Value;
else
end = endIndex.Value;
int start = Start.GetOffset(length);
int end = End.GetOffset(length);

if ((uint)end > (uint)length || (uint)start > (uint)end)
{
Expand Down

0 comments on commit 4ebb3ea

Please sign in to comment.