Re: RFR 8170348: Appendable.appendN(char, int) method to append multiple copies of char

2016-12-11 Thread Peter Levart
Hi Ivan, On 12/11/2016 10:03 PM, Ivan Gerasimov wrote: Thank you Peter for the suggestion! An alternative to a new virtual method on Appendable (or maybe a complement to it) could be a special internal CharSequence implementation (CharRepetitions) with a static factory method on CharSequen

Re: RFR 8170348: Appendable.appendN(char, int) method to append multiple copies of char

2016-12-11 Thread Ivan Gerasimov
Thank you Peter for the suggestion! An alternative to a new virtual method on Appendable (or maybe a complement to it) could be a special internal CharSequence implementation (CharRepetitions) with a static factory method on CharSequence like the following: I think it's a clever idea! Th

Re: RFR 8170348: Appendable.appendN(char, int) method to append multiple copies of char

2016-12-11 Thread Ivan Gerasimov
Thank you Jason for the comments! On 06.12.2016 20:09, Jason Mehrens wrote: Ivan, Will java.util.StringJoiner be modified too? I assume a nCopies char sequence object doesn't pan out performance wise? I don't think I've seen many such uses of StringJoiner as adding the same sequence several

Re: RFR 8170348: Appendable.appendN(char, int) method to append multiple copies of char

2016-12-11 Thread Ivan Gerasimov
Thank you Roger for the comments! On 08.12.2016 1:28, Roger Riggs wrote: Hi Ivan, A few comments... Appendable.appendN default method: I'd expect many time n is small so allocating a new StringBuilder every time seems not optimal. A simple loop with append(c) would have fewer (memory

Re: RFR 8170348: Appendable.appendN(char, int) method to append multiple copies of char

2016-12-11 Thread Ivan Gerasimov
Thank you Paul for the comments and suggestions! Add a fix version of 10, then it’s clear on the intent. Once tests are added :-) we can review for that release. Yes, right. I've set the fix version to 10 and also added the @since 10 tag. I've added a couple of test cases to `test/java/la

Re: RFR 8170348: Appendable.appendN(char, int) method to append multiple copies of char

2016-12-09 Thread Peter Levart
Hi Ivan, On 12/04/2016 01:07 PM, Ivan Gerasimov wrote: Hello! There are several places in JDK where the same character is appended to a StringBuilder object multiple times (usually padding). With each append there are a few routine checks performed. They could have been done only once, if we

Re: RFR 8170348: Appendable.appendN(char, int) method to append multiple copies of char

2016-12-08 Thread Paul Sandoz
> On 8 Dec 2016, at 01:27, Claes Redestad wrote: > > > > On 2016-12-08 10:01, Ulf Zibis wrote: >> Am 08.12.2016 um 09:28 schrieb Peter Levart: >>> >>> On 12/07/2016 11:28 PM, Roger Riggs wrote: AbstractStringBuilder: I agree with Claes' comment suggesting that IAE for negative len

Re: RFR 8170348: Appendable.appendN(char, int) method to append multiple copies of char

2016-12-08 Thread Claes Redestad
On 2016-12-08 10:01, Ulf Zibis wrote: Am 08.12.2016 um 09:28 schrieb Peter Levart: On 12/07/2016 11:28 PM, Roger Riggs wrote: AbstractStringBuilder: I agree with Claes' comment suggesting that IAE for negative lengths is a pain and defining it to append 0 would be natural in many use

Re: RFR 8170348: Appendable.appendN(char, int) method to append multiple copies of char

2016-12-08 Thread Ulf Zibis
Am 08.12.2016 um 09:28 schrieb Peter Levart: On 12/07/2016 11:28 PM, Roger Riggs wrote: AbstractStringBuilder: I agree with Claes' comment suggesting that IAE for negative lengths is a pain and defining it to append 0 would be natural in many use cases. OTOH, inserting a simple Math.m

Re: RFR 8170348: Appendable.appendN(char, int) method to append multiple copies of char

2016-12-08 Thread Peter Levart
On 12/07/2016 11:28 PM, Roger Riggs wrote: AbstractStringBuilder: I agree with Claes' comment suggesting that IAE for negative lengths is a pain and defining it to append 0 would be natural in many use cases. OTOH, inserting a simple Math.max(n, 0) instead of n where n could get nega

Re: RFR 8170348: Appendable.appendN(char, int) method to append multiple copies of char

2016-12-07 Thread Roger Riggs
Hi Ivan, A few comments... Appendable.appendN default method: I'd expect many time n is small so allocating a new StringBuilder every time seems not optimal. A simple loop with append(c) would have fewer (memory) side effects. And in particular for n=0, it could avoid doing anything

Re: RFR 8170348: Appendable.appendN(char, int) method to append multiple copies of char

2016-12-06 Thread Jason Mehrens
s-dev@openjdk.java.net Subject: RFR 8170348: Appendable.appendN(char, int) method to append multiple copies of char Hello! There are several places in JDK where the same character is appended to a StringBuilder object multiple times (usually padding). With each append there are a few routine c

Re: RFR 8170348: Appendable.appendN(char, int) method to append multiple copies of char

2016-12-05 Thread Paul Sandoz
> On 4 Dec 2016, at 08:42, Ivan Gerasimov wrote: > > Thank you Claes for looking into it! > > > On 04.12.2016 16:48, Claes Redestad wrote: >> Hi Ivan, >> >> as this adds a new public API I guess it's too late for 9 at this point, but >> here's a few >> comments anyhow: >> > Yes, of course.

Re: RFR 8170348: Appendable.appendN(char, int) method to append multiple copies of char

2016-12-04 Thread Ivan Gerasimov
Thank you Claes for looking into it! On 04.12.2016 16:48, Claes Redestad wrote: Hi Ivan, as this adds a new public API I guess it's too late for 9 at this point, but here's a few comments anyhow: Yes, of course. If people find it useful, I would expect it to go to jdk 10. - you could use

Re: RFR 8170348: Appendable.appendN(char, int) method to append multiple copies of char

2016-12-04 Thread Claes Redestad
Hi Ivan, as this adds a new public API I guess it's too late for 9 at this point, but here's a few comments anyhow: - you could use Arrays.fill(byte[], int, int, byte) for LATIN-1 case in AbstractStringBuilder. Might not make it much faster (unless there are intrinsics at play, but perhaps a

RFR 8170348: Appendable.appendN(char, int) method to append multiple copies of char

2016-12-04 Thread Ivan Gerasimov
Hello! There are several places in JDK where the same character is appended to a StringBuilder object multiple times (usually padding). With each append there are a few routine checks performed. They could have been done only once, if we had a method for appending multiple copies at a time. A