StringBuilder instead of StringBuffer in java.util package

Iris Clark iris.clark at oracle.com
Tue Apr 22 17:14:28 UTC 2014


Hi, Paul.

> Do you want to become an openJDK contributor? I don't see you in the OpenJDK census.
>
> If you become a contributor:
>
>  http://openjdk.java.net/contribute/
>
> then i can directly accept patches from you and commit them with you as the author

I'm sure this is what you meant, but just to be clear...

To directly accept Octavio's patches, he would need to be an Author for the Project as described on this page [1].
 
"Contributor" means we can accept his changes because he's signed an OCA [2] and his name appears on the Signatories List [3].  We acknowledge Contributors in the "Contributed-by:" field of changeset comments [4].

Thanks,
Iris

[1]: http://openjdk.java.net/projects/#project-author
[2]: http://www.oracle.com/technetwork/oca-405177.pdf
[3]: http://www.oracle.com/technetwork/community/oca-486395.html
[4]: http://openjdk.java.net/guide/producingChangeset.html#changesetComment

-----Original Message-----
From: Paul Sandoz 
Sent: Tuesday, April 22, 2014 5:06 AM
Cc: core-libs-dev at openjdk.java.net
Subject: Re: StringBuilder instead of StringBuffer in java.util package

Hi Otávio,

These look like good finds. I bet there are lots more of them. 

IntelliJ reports 284 possible uses in src/share/classes (see the "'StringBuffer' may be 'StringBuilder'" migration aid), but i have not verified all those. Perhaps we should do this more systematically over all the Java source?

--

Do you want to become an openJDK contributor? I don't see you in the OpenJDK census.

If you become a contributor:

  http://openjdk.java.net/contribute/

then i can directly accept patches from you and commit them with you as the author

Paul.

On Apr 22, 2014, at 1:28 AM, Otávio Gonçalves de Santana <otaviojava at java.net> wrote:

> diff -r 57c1da89ae1a src/share/classes/java/util/prefs/Base64.java
> --- a/src/share/classes/java/util/prefs/Base64.java Wed Apr 16 
> 12:32:36
> 2014 -0700
> +++ b/src/share/classes/java/util/prefs/Base64.java Mon Apr 21 
> +++ 20:20:57
> 2014 -0300
> @@ -57,7 +57,7 @@
>         int numFullGroups = aLen/3;
>         int numBytesInPartialGroup = aLen - 3*numFullGroups;
>         int resultLen = 4*((aLen + 2)/3);
> -        StringBuffer result = new StringBuffer(resultLen);
> +        StringBuilder result = new StringBuilder(resultLen);
>         char[] intToAlpha = (alternate ? intToAltBase64 : 
> intToBase64);
> 
>         // Translate all full groups from byte array elements to 
> Base64 @@ -259,3 +259,4 @@
>         }
>     }
> }
> +
> 
> 
> diff -r 57c1da89ae1a
> src/share/classes/java/util/regex/PatternSyntaxException.java
> --- a/src/share/classes/java/util/regex/PatternSyntaxException.java 
> Wed Apr
> 16 12:32:36 2014 -0700
> +++ b/src/share/classes/java/util/regex/PatternSyntaxException.java 
> +++ Mon Apr
> 21 20:21:52 2014 -0300
> @@ -105,7 +105,7 @@
>      * @return  The full detail message
>      */
>     public String getMessage() {
> -        StringBuffer sb = new StringBuffer();
> +        StringBuilder sb = new StringBuilder();
>         sb.append(desc);
>         if (index >= 0) {
>             sb.append(" near index "); @@ -122,3 +122,4 @@
>     }
> 
> }
> +
> 
> 
> diff -r 57c1da89ae1a src/share/classes/java/util/Properties.java
> --- a/src/share/classes/java/util/Properties.java Wed Apr 16 12:32:36 
> 2014
> -0700
> +++ b/src/share/classes/java/util/Properties.java Mon Apr 21 20:22:44 
> +++ 2014
> -0300
> @@ -602,7 +602,7 @@
>         if (bufLen < 0) {
>             bufLen = Integer.MAX_VALUE;
>         }
> -        StringBuffer outBuffer = new StringBuffer(bufLen);
> +        StringBuilder outBuffer = new StringBuilder(bufLen);
> 
>         for(int x=0; x<len; x++) {
>             char aChar = theString.charAt(x); @@ -1209,3 +1209,4 @@
>         }
>     }
> }
> +
> 
> --
> Atenciosamente.
> 
> Otávio Gonçalves de Santana
> 
> blog:     http://otaviosantana.blogspot.com.br/
> twitter: http://twitter.com/otaviojava
> site:     http://www.otaviojava.com.br
> (11)     98255-3513




More information about the core-libs-dev mailing list