Re: [PATCH] minor regex cleanup: use switch for enum

2018-04-24 Thread Remi Forax
nvoyé: Mardi 24 Avril 2018 14:17:21 > Objet: Re: [PATCH] minor regex cleanup: use switch for enum > On 04/24/2018 12:41 PM, Peter Levart wrote: >> public class Code {l >> >>     static class m$switch$1 { >>         static final int[] caseindex = new in

Re: [PATCH] minor regex cleanup: use switch for enum

2018-04-24 Thread Remi Forax
), so if this is true, all fields of java.lang should be trusted by the VM. regards, Rémi - Mail original - > De: "Peter Levart" > À: "David Lloyd" , "Xueming Shen" > > Cc: "core-libs-dev" > Envoyé: Mardi 24 Avril 2018 14:17:21 &

Re: [PATCH] minor regex cleanup: use switch for enum

2018-04-24 Thread David Lloyd
On Mon, Apr 23, 2018 at 7:42 PM, Isaac Levy wrote: > On Mon, Apr 23, 2018 at 5:18 PM David Lloyd wrote: >> >> FWIW I strongly doubt this will improve performance; probably the >> opposite in fact, as IIRC an enum switch generates an extra class >> (though perhaps this has changed). The original

Re: [PATCH] minor regex cleanup: use switch for enum

2018-04-24 Thread Peter Levart
On 04/24/2018 12:41 PM, Peter Levart wrote: public class Code {l     static class m$switch$1 {         static final int[] caseindex = new int[X.values().length];     static {             caseindex[X.A.ordinal()] = 1;             caseindex[X.B.ordinal()] = 2;             caseindex[X.C.ordin

Re: [PATCH] minor regex cleanup: use switch for enum

2018-04-24 Thread Peter Levart
On 04/23/2018 11:18 PM, David Lloyd wrote: FWIW I strongly doubt this will improve performance; probably the opposite in fact, as IIRC an enum switch generates an extra class (though perhaps this has changed). switch on enum is basically a switch on Enum's ordinal mapped via the int[] array

Re: [PATCH] minor regex cleanup: use switch for enum

2018-04-23 Thread Isaac Levy
On Mon, Apr 23, 2018 at 5:05 PM Xueming Shen wrote: > > I would assume in case of an exception thrown from > appendExpandedReplacement() we don't > want "text" to be pushed into the "sb". > > -sherman > Perhaps. Though the behavior under exception is undefined and this function is probably prima

Re: [PATCH] minor regex cleanup: use switch for enum

2018-04-23 Thread Isaac Levy
On Mon, Apr 23, 2018 at 5:18 PM David Lloyd wrote: > FWIW I strongly doubt this will improve performance; probably the > opposite in fact, as IIRC an enum switch generates an extra class > (though perhaps this has changed). The original code was quite > compact and utilized identity comparisons,

Re: [PATCH] minor regex cleanup: use switch for enum

2018-04-23 Thread David Lloyd
FWIW I strongly doubt this will improve performance; probably the opposite in fact, as IIRC an enum switch generates an extra class (though perhaps this has changed). The original code was quite compact and utilized identity comparisons, and given there are only three alternatives it probably was

Re: [PATCH] minor regex cleanup: use switch for enum

2018-04-23 Thread Xueming Shen
I would assume in case of an exception thrown from appendExpandedReplacement() we don't want "text" to be pushed into the "sb". -sherman On 4/23/18, 1:49 PM, Isaac Levy wrote: Thanks. Another small perf patch below -- maybe we can combine. Avoids a StringBuilder allocation: --- a/src/java.

Re: [PATCH] minor regex cleanup: use switch for enum

2018-04-23 Thread Isaac Levy
Thanks. Another small perf patch below -- maybe we can combine. Avoids a StringBuilder allocation: --- a/src/java.base/share/classes/java/util/regex/Matcher.java +++ b/src/java.base/share/classes/java/util/regex/Matcher.java @@ -993,13 +993,11 @@ public Matcher appendReplacement(StringBuilder

Re: [PATCH] minor regex cleanup: use switch for enum

2018-04-23 Thread Xueming Shen
this looks fine. -sherman On 4/23/18, 12:26 PM, Isaac Levy wrote: ping? Isaac On Wed, Apr 18, 2018 at 2:58 PM, Isaac Levy wrote: Hi, Minor improvement in readability (and probably perf) for Pattern. Switch is more consistent with the rest of the impl and the resulting tableswitch avoids

Re: [PATCH] minor regex cleanup: use switch for enum

2018-04-23 Thread Isaac Levy
ping? Isaac On Wed, Apr 18, 2018 at 2:58 PM, Isaac Levy wrote: > Hi, > > Minor improvement in readability (and probably perf) for Pattern. Switch > is more consistent with the rest of the impl and the resulting tableswitch > avoids a comparison for possessives. > > -Isaac > > --- a/src/java.ba

[PATCH] minor regex cleanup: use switch for enum

2018-04-18 Thread Isaac Levy
Hi, Minor improvement in readability (and probably perf) for Pattern. Switch is more consistent with the rest of the impl and the resulting tableswitch avoids a comparison for possessives. -Isaac --- a/src/java.base/share/classes/java/util/regex/Pattern.java +++ b/src/java.base/share/classes/jav