summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew John Hughes <ahughes@redhat.com>2012-05-01 15:37:19 +0100
committerAndrew John Hughes <ahughes@redhat.com>2012-05-01 15:37:19 +0100
commit8f5047352c3d318df8e691373d9a89fde64c9245 (patch)
tree67b3e04f0073ee2c58c9fd8efa46f0ff7f38e593
parent1ad13cff0a76cd9bdaa22afcc94c4ccb96af8bab (diff)
downloadclasspath-8f5047352c3d318df8e691373d9a89fde64c9245.tar.gz
Cache the compiled regular expressions for splitting locale data fields.
2012-05-01 Andrew John Hughes <ahughes@redhat.com> * 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 <sewe@st.informatik.tu-darmstadt.de> * 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 <ahughes@redhat.com>
-rw-r--r--ChangeLog17
-rw-r--r--THANKYOU1
-rw-r--r--java/text/DateFormatSymbols.java11
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 <ahughes@redhat.com>
+
+ * 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 <sewe@st.informatik.tu-darmstadt.de>
+
+ * 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 <ahughes@redhat.com>
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");