harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tim Ellison <t.p.elli...@gmail.com>
Subject Re: svn commit: r772849 - /harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/AbstractStringBuilder.java
Date Fri, 08 May 2009 09:26:41 GMT
Doesn't this break the spec for ensureCapacity [1]?

It seems to cause a test case failure for me:

expected:<12> but was:<10>

junit.framework.AssertionFailedError: expected:<12> but was:<10>
at
org.apache.harmony.luni.tests.java.lang.StringBuilderTest.test_ensureCapacityI(StringBuilderTest.java:624)

[1]
http://java.sun.com/j2se/1.5.0/docs/api/java/lang/StringBuilder.html#ensureCapacity(int)

Regards,
Tim


regisxu@apache.org wrote:
> Author: regisxu
> Date: Fri May  8 05:54:20 2009
> New Revision: 772849
> 
> URL: http://svn.apache.org/viewvc?rev=772849&view=rev
> Log:
> enlarge half size of buffer to reduce wasted memory
> 
> Modified:
>     harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/AbstractStringBuilder.java
> 
> Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/AbstractStringBuilder.java
> URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/AbstractStringBuilder.java?rev=772849&r1=772848&r2=772849&view=diff
> ==============================================================================
> --- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/AbstractStringBuilder.java
(original)
> +++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/AbstractStringBuilder.java
Fri May  8 05:54:20 2009
> @@ -91,8 +91,8 @@
>      }
>  
>      private void enlargeBuffer(int min) {
> -        int twice = (value.length << 1) + 2;
> -        char[] newData = new char[min > twice ? min : twice];
> +        int newSize = (value.length >> 1 + value.length) + 2;
> +        char[] newData = new char[min > newSize ? min : newSize];
>          System.arraycopy(value, 0, newData, 0, count);
>          value = newData;
>          shared = false;
> 
> 
> 

Mime
View raw message