Skip to content

Commit 26ea478

Browse files
committed
Shape: minor cleanup of redundant code
1 parent 22042c3 commit 26ea478

1 file changed

Lines changed: 8 additions & 26 deletions

File tree

src/NumSharp.Core/View/Shape.cs

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -857,32 +857,13 @@ public int[] GetCoordinates(int offset)
857857

858858
if (strides.Length == 1)
859859
coords = new int[] { offset };
860-
else if (layout == 'C')
861-
{
862-
int counter = offset;
863-
coords = new int[strides.Length];
864-
int stride;
865-
for (int i = 0; i < strides.Length; i++)
866-
{
867-
stride = strides[i];
868-
if (stride == 0)
869-
{
870-
coords[i] = 0;
871-
}
872-
else
873-
{
874-
coords[i] = counter / stride;
875-
counter -= coords[i] * stride;
876-
}
877-
}
878-
}
879-
else
860+
861+
int counter = offset;
862+
coords = new int[strides.Length];
863+
int stride;
864+
for (int i = 0; i < strides.Length; i++)
880865
{
881-
int counter = offset;
882-
coords = new int[strides.Length];
883-
int stride;
884-
for (int i = strides.Length - 1; i >= 0; i--)
885-
{
866+
unchecked {
886867
stride = strides[i];
887868
if (stride == 0)
888869
{
@@ -894,7 +875,8 @@ public int[] GetCoordinates(int offset)
894875
counter -= coords[i] * stride;
895876
}
896877
}
897-
}
878+
}
879+
898880
return coords;
899881
}
900882

0 commit comments

Comments
 (0)