Re: Replace concat String to append in StringBuilder parameters

2014-08-30 Thread Otávio Gonçalves de Santana
I believe yes. Using the -XX:+OptimizeStringConcat: java -jar -XX:+OptimizeStringConcat target/microbenchmarks.jar .*StringBuilderConcatBenchMark.* -wi 10 -i 10 -f 1 The same thing happened: Benchmark Mode Samples Mean Mean error

Re: Replace concat String to append in StringBuilder parameters

2014-08-29 Thread Wang Weijun
So it's not that the optimization fails but there is no optimization on them yet. I do see the .append(x) case will be easy to deal with, but it looks like historically javac has not been a place to do many optimizations. It mostly converts the java source to byte codes in a 1-to-1 mapping and

Re: Replace concat String to append in StringBuilder parameters

2014-08-28 Thread Ulf Zibis
I mean: It does not output byte code that only uses a single char array to compose the entire String in question. With optimization fails, I also mean, there is used an additional StringComposer e.g. another StringBuilder or a StringJoiner in addition to the 1st StringBuilder. -Ulf Am

Re: Replace concat String to append in StringBuilder parameters

2014-08-27 Thread Ulf Zibis
Hi all, a critical question! 1.) Why we have String concatenation in Java? ... I would answer: for _readability_ purpose. 2.) In the early javac times, we were asked to refactor to StringBuffer for performance critical code. 3.) Since 1.6 ? javac is capable to replace multiple concatenation

Re: Replace concat String to append in StringBuilder parameters

2014-08-27 Thread Pavel Rappo
Could you please explain what you mean by javac optimization fails here? -Pavel On 27 Aug 2014, at 10:41, Ulf Zibis ulf.zi...@cosoco.de wrote: 4.) Now we see, that javac optimization fails again if StringBuilder, concatenation, toString(), append(String), append(Collection) etc. and

Re: Replace concat String to append in StringBuilder parameters

2014-08-21 Thread Wang Weijun
I filed a bug at https://bugs.openjdk.java.net/browse/JDK-8038277 Webrev in 3 parts at http://cr.openjdk.java.net/~weijun/8038277/client/webrev.00 http://cr.openjdk.java.net/~weijun/8038277/core/webrev.00/ http://cr.openjdk.java.net/~weijun/8038277/extra/webrev.00/ --Max On Aug

Re: Replace concat String to append in StringBuilder parameters

2014-08-21 Thread Andrej Golovnin
https://bugs.openjdk.java.net/browse/JDK-8038277 This is not the right bug report. The subject of this bug report is Improve the bootstrap performance of carets keystore. http://cr.openjdk.java.net/~weijun/8038277/client/webrev.00 TABs are still used for indentation. I looked only

Re: Replace concat String to append in StringBuilder parameters

2014-08-21 Thread Martin Desruisseaux
I had a random look at the Webrev for TreeModelEvent.java and saw the following new code: sb.append(Integer.toString(childIndices[counter])) Wouldn't the following be slightly more efficient? sb.append(childIndices[counter]) since Integer.toString(int) creates a temporary char[] array

Re: Replace concat String to append in StringBuilder parameters

2014-08-21 Thread Andrej Golovnin
Hi Martin, you are right. And in the line 297: 297 sb.append(getClass().getName()).append(' ').append(Integer.toString(hashCode())); Integer.toString() can be removed too. Best regards, Andrej Golovnin On Thu, Aug 21, 2014 at 3:26 PM, Martin Desruisseaux

Re: Replace concat String to append in StringBuilder parameters

2014-08-21 Thread Wang Weijun
On Aug 21, 2014, at 21:18, Andrej Golovnin andrej.golov...@gmail.com wrote: https://bugs.openjdk.java.net/browse/JDK-8038277 This is not the right bug report. The subject of this bug report is Improve the bootstrap performance of carets keystore. Oh, my mistake, it should be

Re: Replace concat String to append in StringBuilder parameters

2014-08-21 Thread Wang Weijun
I also see a lot of .toString() and String.valueOf() calls. $ cat string_concat_updated.patch | perl -ne 'print if /^\+ .*append.*(String\.valueOf|\.toString\(\))/' | wc 62 2104626 Wrapped lines not indented correctly in

Re: Replace concat String to append in StringBuilder parameters

2014-08-19 Thread Pavel Rappo
Brian, Yes, this works fine in cases when 'whatever' is a j.u.Collection? extends CharSequence (though some may argue that it's an overkill already). However we need even more thinking and transformations in case when 'whatever' is one of these: * j.u.Iterator? extends CharSequence *

Re: Replace concat String to append in StringBuilder parameters

2014-08-19 Thread Sergey Bylokhov
Hi Otávio, The new alignment in DataLine.java/JColorChooser.java looks strange. Wrong change in BasicTableUI.java: -plainStr.deleteCharAt(plainStr.length() - 1).append(\n); +plainStr.deleteCharAt(plainStr.length() - 1).append('\t'); On 13.08.2014 3:01,

Re: Replace concat String to append in StringBuilder parameters

2014-08-19 Thread Wang Weijun
Hi Otávio I see TABs in the first page of sun_security.diff, too long line in javax_security.diff. Also, it's unfortunate that you will need to rename the file names to the new style with modules. See http://cr.openjdk.java.net/~chegar/docs/portingScript.html for how to do this. I can create

Re: Replace concat String to append in StringBuilder parameters

2014-08-18 Thread Brian Goetz
What you should have written was: String s = whatever.stream().collect(joining(, )); On 8/11/2014 1:31 PM, Pavel Rappo wrote: Sorry, I should've written this: Iterable? whatever = ... StringJoiner joiner = new StringJoiner(, ); whatever.forEach(w -

Re: Replace concat String to append in StringBuilder parameters

2014-08-15 Thread Otávio Gonçalves de Santana
Could anyone help me as sponsor, please? On Tue, Aug 12, 2014 at 8:01 PM, Otávio Gonçalves de Santana otavioj...@java.net wrote: Thank you Roger. Done https://dl.dropboxusercontent.com/u/16109193/open_jdk/string_builder_concat_6.zip On Tue, Aug 12, 2014 at 10:15 AM, roger riggs

Re: Replace concat String to append in StringBuilder parameters

2014-08-12 Thread Andrej Golovnin
Hi Otávio, I think you should fix the indentation in a lot of classes. You use the tab-character for the indentation. As far as I know we should use the space character for the indentation in the JDK sources (Oracle devs feel free to correct me if I'm wrong. And it would be really nice if the

Re: Replace concat String to append in StringBuilder parameters

2014-08-12 Thread roger riggs
fyi, There's a Perl script normalizer.pl that detects/fixes most of the simple tab/white space issues. The script is in the repo/make/scripts/normalizer.pl Roger On 8/12/2014 3:48 AM, Andrej Golovnin wrote: Hi Otávio, I think you should fix the indentation in a lot of classes. You use the

Re: Replace concat String to append in StringBuilder parameters

2014-08-11 Thread Andrej Golovnin
Hi Otávio, the class src/share/classes/com/sun/jmx/snmp/IPAcl/Parser.java is generated from the grammar src/share/classes/com/sun/jmx/snmp/IPAcl/Parser.jjt src/share/classes/com/sun/jmx/snmp/IPAcl/Parser.jj Therefore when you are going to change the Parser class, then you must change the

Re: Replace concat String to append in StringBuilder parameters

2014-08-11 Thread Pavel Rappo
In the class src/share/classes/javax/management/openmbean/CompositeType.java you have added the annotation @SuppressWarnings(StringConcatenationInsideStringBufferAppend) instead of fixing the concatenation inside the append method. Why? +1 Moreover, I wonder where this value comes from? I've

Re: Replace concat String to append in StringBuilder parameters

2014-08-11 Thread Andrej Golovnin
Hi Otávio, About the template in Parser.jjt, TokenMgrError.java, etc. I don't know how can do that. Can anyone help me? See attached diff for the changes in Parser.jjt and Parser.jj. For the TokenMgrError and ParserException you can just subscribe here: https://java.net/projects/javacc/lists

Re: Replace concat String to append in StringBuilder parameters

2014-08-11 Thread Andrej Golovnin
Hi Otávio, please ignore the previous diff. I'm sorry, there was a small mistake. I have attached the corrected version. Best regards, Andrej Golovnin On Mon, Aug 11, 2014 at 1:55 PM, Andrej Golovnin andrej.golov...@gmail.com wrote: Hi Otávio, About the template in Parser.jjt,

Re: Replace concat String to append in StringBuilder parameters

2014-08-11 Thread Andrej Golovnin
Hi, About readable of code I just renamed this class to sb instead of buf, strbuf, etc. I doubt that renaming variables does really improve the code readability. And you changed the indentation (take look at other classes too): 239 public String toString() { 240 StringBuilder sb

Re: Replace concat String to append in StringBuilder parameters

2014-08-11 Thread Ivan Gerasimov
Hi Otávio! A few days ago I've posted another cleanup request, which included modifications to src/share/classes/sun/net/www/MimeEntry.java http://mail.openjdk.java.net/pipermail/core-libs-dev/2014-August/028131.html As our changes overlap, one should be reverted back. I believe using

Re: Replace concat String to append in StringBuilder parameters

2014-08-11 Thread Ulf Zibis
Am 11.08.2014 um 15:12 schrieb Andrej Golovnin: In the most classes I mentioned in my previous mail only the #toString()-methods would be affected by the proposal. And in the most cases, maybe in all cases, the #toString()-methods in this classes exists only to provide nice output. So why not

Re: Replace concat String to append in StringBuilder parameters

2014-08-11 Thread Pavel Rappo
Otavio, Just skimmed through your changes. It looks good. But there are some things we can make a little bit better though. IMO, it's not always a performance that matters (looking around to see if Alexey Shipilev is somewhere near) but readability. It's good to estimate performance

Re: Replace concat String to append in StringBuilder parameters

2014-08-11 Thread Ulf Zibis
Am 11.08.2014 um 16:33 schrieb Pavel Rappo: Unfortunately, neither java.util.StringJoiner nor String.join have perfect (but who has?) APIs. So it's up to us to figure out the best way of joining elements. Maybe remember my thoughts from here:

Re: Replace concat String to append in StringBuilder parameters

2014-08-11 Thread Pavel Rappo
Ulf, My point was simply that none of these classes provide methods that accept java.lang.Object. IMO, the scenario when we join elements into a String by calling toString on each element prior to append it -- is the most common scenario (maybe except for when element is a String itself). That

Re: Replace concat String to append in StringBuilder parameters

2014-08-11 Thread Pavel Rappo
Sorry, I should've written this: Iterable? whatever = ... StringJoiner joiner = new StringJoiner(, ); whatever.forEach(w - joiner.add(w.toString())); String s = joiner.toString(); -Pavel On 11 Aug 2014, at 17:17, Pavel Rappo pavel.ra...@oracle.com wrote:

Re: Replace concat String to append in StringBuilder parameters

2014-08-10 Thread Ulf Zibis
Hi Otávio, this is a great proposal. Little nit: In cases where only 1 character is to append, I guess append(char) would be faster and at least will save footprint in contrast to append(String). -Ulf Am 10.08.2014 um 23:33 schrieb Otávio Gonçalves de Santana: *Motivation:* Make another

Re: Replace concat String to append in StringBuilder parameters

2014-08-10 Thread Claes Redestad
+1 Some suggestions (mostly nits): - in places like src/share/classes/java/util/regex/Pattern.java you introducesingle-char strings which might use a char instead: -result.append(|+next); +result.append('|').append(next); - in places like

Re: Replace concat String to append in StringBuilder parameters

2014-08-10 Thread Ulf Zibis
Am 11.08.2014 um 01:03 schrieb Claes Redestad: - in places like src/share/classes/sun/security/provider/PolicyFile.java you end up with a sequence of String literal appends which could be merged into one: -sb.append(principalInfo[i][0] + + -\ +