From 8f5047352c3d318df8e691373d9a89fde64c9245 Mon Sep 17 00:00:00 2001 From: Andrew John Hughes Date: Tue, 1 May 2012 15:37:19 +0100 Subject: Cache the compiled regular expressions for splitting locale data fields. 2012-05-01 Andrew John Hughes * java/text/DateFormatSymbols.java: Rename U00AE and U000A9 as the more memorable FIELD_SPLIT and ZONE_SPLIT respectively. * THANKYOU: Add Andreas Sewe. 2012-04-30 Andreas Sewe * java/text/DateFormatSymbols.java: (U00A9): Pre-compile pattern for zone separation. (U00AE): Likewise for fields. (getStringArray(List,String,int,String)): Use U00AE.split in place of String.split. (getZoneStrings(ResourceBundle,Locale)): Use U00AE.split and U00A9.split in place of String.split. Signed-off-by: Andrew John Hughes --- ChangeLog | 17 +++++++++++++++++ THANKYOU | 1 + java/text/DateFormatSymbols.java | 11 ++++++++--- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7d6ab7bcb..31833447b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +2012-05-01 Andrew John Hughes + + * java/text/DateFormatSymbols.java: + Rename U00AE and U000A9 as the more memorable + FIELD_SPLIT and ZONE_SPLIT respectively. + * THANKYOU: Add Andreas Sewe. + +2012-04-30 Andreas Sewe + + * java/text/DateFormatSymbols.java: + (U00A9): Pre-compile pattern for zone separation. + (U00AE): Likewise for fields. + (getStringArray(List,String,int,String)): Use U00AE.split + in place of String.split. + (getZoneStrings(ResourceBundle,Locale)): Use U00AE.split + and U00A9.split in place of String.split. + 2012-04-25 Andrew John Hughes Update warning suppression so it still works diff --git a/THANKYOU b/THANKYOU index 21e75c84e..e6ffb4c63 100644 --- a/THANKYOU +++ b/THANKYOU @@ -43,6 +43,7 @@ Petter Reinholdtsen (pere@hungry.com) Julian Scheid (julian.scheid@sektor37.de) Martin Schröder (ms@artcom-gmbh.de) Robert Schuster (robertschuster@fsfe.org) +Andreas Sewe (sewe@st.informatik.tu-darmstadt.de) Gaute Smaaland (gs@sevenmountains.no) Michael Smith (msmith@spinnakernet.com) J. Russell Smyth (drfish@uswest.net) diff --git a/java/text/DateFormatSymbols.java b/java/text/DateFormatSymbols.java index 53e7ba07c..6b0d3a13f 100644 --- a/java/text/DateFormatSymbols.java +++ b/java/text/DateFormatSymbols.java @@ -55,6 +55,7 @@ import java.util.Properties; import java.util.ResourceBundle; import java.util.ServiceLoader; import java.util.TimeZone; +import java.util.regex.Pattern; import java.util.spi.TimeZoneNameProvider; @@ -100,6 +101,10 @@ public class DateFormatSymbols implements java.io.Serializable, Cloneable } } + private static final Pattern ZONE_SEP = Pattern.compile("\u00a9"); + + private static final Pattern FIELD_SEP = Pattern.compile("\u00ae"); + /** * The timezone strings supplied by the runtime. */ @@ -161,7 +166,7 @@ public class DateFormatSymbols implements java.io.Serializable, Cloneable for (int a = 0; a < bundles.size(); ++a) { String localeData = bundles.get(a).getString(name); - String[] array = localeData.split("\u00ae", size); + String[] array = FIELD_SEP.split(localeData, size); for (int b = 0; b < data.length; ++b) { if (array.length > b && array[b] != null && data[b].isEmpty() && !array[b].isEmpty()) @@ -191,10 +196,10 @@ public class DateFormatSymbols implements java.io.Serializable, Cloneable int index = 0; String country = locale.getCountry(); String data = res.getString("zoneStrings"); - String[] zones = data.split("\u00a9"); + String[] zones = ZONE_SEP.split(data); for (int a = 0; a < zones.length; ++a) { - String[] strings = zones[a].split("\u00ae"); + String[] strings = FIELD_SEP.split(zones[a]); String type = properties.getProperty(strings[0] + "." + country); if (type == null) type = properties.getProperty(strings[0] + ".DEFAULT"); -- cgit v1.2.1