Skip to content

Commit

Permalink
Swap using the provided indexes (dotnet#55331)
Browse files Browse the repository at this point in the history
SwapElements is passed two indexes, however, it ignored the second index
and instead used `index + 1`. It just so happened that the caller used
`index + 1` as the second index, but that might not have been the case.
  • Loading branch information
pbiggar authored Oct 25, 2021
1 parent c1d6d84 commit 80de47a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/coreclr/tools/Common/Sorting/ArrayAccessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public void SetElement(T[] dataStructure, int i, T value)
public void SwapElements(T[] dataStructure, int i, int i2)
{
T temp = dataStructure[i];
dataStructure[i] = dataStructure[i + 1];
dataStructure[i + 1] = temp;
dataStructure[i] = dataStructure[i2];
dataStructure[i2] = temp;
}
}
}
4 changes: 2 additions & 2 deletions src/coreclr/tools/Common/Sorting/ListAccessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ public void SetElement(List<T> dataStructure, int i, T value)
public void SwapElements(List<T> dataStructure, int i, int i2)
{
T temp = dataStructure[i];
dataStructure[i] = dataStructure[i + 1];
dataStructure[i + 1] = temp;
dataStructure[i] = dataStructure[i2];
dataStructure[i2] = temp;
}
}
}

0 comments on commit 80de47a

Please sign in to comment.