You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by er...@apache.org on 2020/06/06 21:55:01 UTC
[commons-math] 01/02: use subList().clear instead of a loop of
remove(0)
This is an automated email from the ASF dual-hosted git repository.
erans pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-math.git
commit e34ea727ca72599081f091a08e41d1ba3f5dbdd1
Author: XenoAmess <xe...@gmail.com>
AuthorDate: Fri Jun 5 04:20:29 2020 +0800
use subList().clear instead of a loop of remove(0)
---
.../org/apache/commons/math4/stat/descriptive/ListUnivariateImpl.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/test/java/org/apache/commons/math4/stat/descriptive/ListUnivariateImpl.java b/src/test/java/org/apache/commons/math4/stat/descriptive/ListUnivariateImpl.java
index cf15b93..132c4a3 100644
--- a/src/test/java/org/apache/commons/math4/stat/descriptive/ListUnivariateImpl.java
+++ b/src/test/java/org/apache/commons/math4/stat/descriptive/ListUnivariateImpl.java
@@ -197,8 +197,8 @@ public class ListUnivariateImpl extends DescriptiveStatistics implements Seriali
//Discard elements from the front of the list if the windowSize is less than
// the size of the list.
int extra = list.size() - windowSize;
- for (int i = 0; i < extra; i++) {
- list.remove(0);
+ if (extra > 0) {
+ list.subList(0, extra).clear();
}
}