Skip to content

Commit

Permalink
Performance pass #3 (Manual array copies)
Browse files Browse the repository at this point in the history
Took 1 minute
  • Loading branch information
Andrew committed Sep 12, 2020
1 parent 9a7ab90 commit 56ac439
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -319,10 +319,7 @@ else if(c.getName().equalsIgnoreCase(Info.COMMAND_REACT))
{
String[] args = new String[a.length - 1];

for(int i = 1; i < a.length; i++)
{
args[i - 1] = a[i];
}
System.arraycopy(a, 1, args, 0, a.length - 1);

cmd.fire(plr ? px : s, args);
}
Expand Down
5 changes: 1 addition & 4 deletions src/main/java/com/volmit/react/util/DoubleArrayUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ public class DoubleArrayUtils
{
public static void shiftRight(double[] values, double push)
{
for(int index = values.length - 2; index >= 0; index--)
{
values[index + 1] = values[index];
}
if (values.length - 2 + 1 >= 0) System.arraycopy(values, 0, values, 1, values.length - 2 + 1);

values[0] = push;
}
Expand Down
5 changes: 1 addition & 4 deletions src/main/java/primal/compute/math/DoubleArrayUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ public class DoubleArrayUtils
{
public static void shiftRight(double[] values, double push)
{
for(int index = values.length - 2; index >= 0; index--)
{
values[index + 1] = values[index];
}
if (values.length - 2 + 1 >= 0) System.arraycopy(values, 0, values, 1, values.length - 2 + 1);

values[0] = push;
}
Expand Down

0 comments on commit 56ac439

Please sign in to comment.