Repository: commons-math Updated Branches: refs/heads/master 441687e5a -> 8be87e032
MATH-1229 Set initial capacity to input array's size in order to avoid unnecessary resizing for inputs larger than than the default capacity. Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-math/commit/8be87e03 Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/8be87e03 Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/8be87e03 Branch: refs/heads/master Commit: 8be87e032a8c05622148357f30bdca3c614a669f Parents: 441687e Author: Gilles <[email protected]> Authored: Sat May 30 19:23:35 2015 +0200 Committer: Gilles <[email protected]> Committed: Sat May 30 19:23:35 2015 +0200 ---------------------------------------------------------------------- .../org/apache/commons/math4/util/ResizableDoubleArray.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/commons-math/blob/8be87e03/src/main/java/org/apache/commons/math4/util/ResizableDoubleArray.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/math4/util/ResizableDoubleArray.java b/src/main/java/org/apache/commons/math4/util/ResizableDoubleArray.java index 09fd748..f5292c4 100644 --- a/src/main/java/org/apache/commons/math4/util/ResizableDoubleArray.java +++ b/src/main/java/org/apache/commons/math4/util/ResizableDoubleArray.java @@ -179,7 +179,6 @@ public class ResizableDoubleArray implements DoubleArray, Serializable { * The input array is copied, not referenced. * Other properties take default values: * <ul> - * <li>{@code initialCapacity = 16}</li> * <li>{@code expansionMode = MULTIPLICATIVE}</li> * <li>{@code expansionFactor = 2.0}</li> * <li>{@code contractionCriterion = 2.5}</li> @@ -189,7 +188,9 @@ public class ResizableDoubleArray implements DoubleArray, Serializable { * @since 2.2 */ public ResizableDoubleArray(double[] initialArray) { - this(DEFAULT_INITIAL_CAPACITY, + this((initialArray == null || initialArray.length == 0 ? + DEFAULT_INITIAL_CAPACITY : + initialArray.length), DEFAULT_EXPANSION_FACTOR, DEFAULT_CONTRACTION_DELTA + DEFAULT_EXPANSION_FACTOR, DEFAULT_EXPANSION_MODE,
