[ 
https://issues.apache.org/jira/browse/MATH-894?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13496237#comment-13496237
 ] 

Phil Steitz commented on MATH-894:
----------------------------------

I am sorry but I just realized (thanks to the unit test :) that there is a 
downside to this change as it changes the contract of clear.  The removed 
reallocation shrunk the internal array back to initialCapacity in size, as 
stated in the javadoc.  Removing the reallocation leaves the internal array at 
whatever size it was when clear was invoked.  I can imagine usages where after 
expanding an array to be large, someone might want to free the associated 
storage and shrink the array back to the initial capacity, which clear would do 
before this change.  Could be no one depends on / cares about this; but if we 
leave this change in, we should remove the statement about restoring the size 
from the javadoc.
                
> Spurious method call in "ResizableDoubleArray" ("o.a.c.m.util")
> ---------------------------------------------------------------
>
>                 Key: MATH-894
>                 URL: https://issues.apache.org/jira/browse/MATH-894
>             Project: Commons Math
>          Issue Type: Improvement
>    Affects Versions: 3.0
>            Reporter: Gilles
>            Assignee: Gilles
>            Priority: Minor
>             Fix For: 3.1
>
>
> Method "addElement" should not call "contract()", as it will almost always 
> make the storage array shrink on the first call since it will be considered 
> "too big" (for just storing one element).
> See discussion about this change in MATH-757.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to