[
https://issues.apache.org/jira/browse/MATH-1569?focusedWorklogId=818954&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-818954
]
ASF GitHub Bot logged work on MATH-1569:
----------------------------------------
Author: ASF GitHub Bot
Created on: 20/Oct/22 21:49
Start Date: 20/Oct/22 21:49
Worklog Time Spent: 10m
Work Description: aherbert commented on code in PR #219:
URL: https://github.com/apache/commons-math/pull/219#discussion_r1001149401
##########
commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/analysis/function/Logit.java:
##########
@@ -182,9 +182,7 @@ public DerivativeStructure value(final DerivativeStructure
t)
// for x close to hi the signs will always be +inf)
// this is probably overkill, since the call to compose at the end
// of the method will transform most infinities into NaN ...
- for (int i = 2; i < f.length; ++i) {
- f[i] = f[i - 2];
- }
+ if (f.length - 2 >= 0) System.arraycopy(f, 0, f, 2, f.length - 2);
Review Comment:
`> 0`
##########
commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/CMAESOptimizer.java:
##########
@@ -752,9 +752,7 @@ private void updateBD(double negccov) {
* @param val Current best fitness value.
*/
private static void push(double[] vals, double val) {
- for (int i = vals.length-1; i > 0; i--) {
- vals[i] = vals[i-1];
- }
+ if (vals.length - 1 >= 0) System.arraycopy(vals, 0, vals, 1,
vals.length - 1);
Review Comment:
`> 0`
##########
commons-math-legacy-core/src/main/java/org/apache/commons/math4/legacy/core/dfp/Dfp.java:
##########
@@ -663,9 +663,7 @@ public Dfp getTwo() {
/** Shift the mantissa left, and adjust the exponent to compensate.
*/
protected void shiftLeft() {
- for (int i = mant.length - 1; i > 0; i--) {
- mant[i] = mant[i - 1];
- }
+ if (mant.length - 1 >= 0) System.arraycopy(mant, 0, mant, 1,
mant.length - 1);
Review Comment:
use `> 0` as arraycopy with a length of 0 is a wasted call to a native
method. Add enclosing braces to fix checkstyle.
##########
commons-math-legacy-core/src/main/java/org/apache/commons/math4/legacy/core/dfp/Dfp.java:
##########
@@ -675,9 +673,7 @@ uses shiftRight() */
/** Shift the mantissa right, and adjust the exponent to compensate.
*/
protected void shiftRight() {
- for (int i = 0; i < mant.length - 1; i++) {
- mant[i] = mant[i + 1];
- }
+ if (mant.length - 1 >= 0) System.arraycopy(mant, 1, mant, 0,
mant.length - 1);
Review Comment:
`> 0`
##########
commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/ode/nonstiff/AdamsNordsieckFieldTransformer.java:
##########
@@ -170,10 +170,8 @@ private AdamsNordsieckFieldTransformer(final Field<T>
field, final int n) {
// Nordsieck to multistep, then shifting rows to represent step advance
// then applying inverse transform
T[][] shiftedP = bigP.getData();
- for (int i = shiftedP.length - 1; i > 0; --i) {
- // shift rows
- shiftedP[i] = shiftedP[i - 1];
- }
+ // shift rows
+ if (shiftedP.length - 1 >= 0) System.arraycopy(shiftedP, 0, shiftedP,
1, shiftedP.length - 1);
Review Comment:
`> 0`
Issue Time Tracking
-------------------
Worklog Id: (was: 818954)
Time Spent: 50m (was: 40m)
> Manual array copy
> -----------------
>
> Key: MATH-1569
> URL: https://issues.apache.org/jira/browse/MATH-1569
> Project: Commons Math
> Issue Type: Sub-task
> Reporter: Arturo Bernal
> Priority: Minor
> Time Spent: 50m
> Remaining Estimate: 0h
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)