harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r788016 - in /harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text: DateFormatSymbols.java DecimalFormat.java DecimalFormatSymbols.java NumberFormat.java SimpleDateFormat.java
Date Wed, 24 Jun 2009 13:32:38 GMT
Author: tellison
Date: Wed Jun 24 13:32:37 2009
New Revision: 788016

URL: http://svn.apache.org/viewvc?rev=788016&view=rev
Log:
Apply modified version of patch for HARMONY-6241 (java.text.SimpleDateFormat.SimpleDateFormat(String,
Locale) performance can be improved)

Modified:
    harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/DateFormatSymbols.java
    harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/DecimalFormat.java
    harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/DecimalFormatSymbols.java
    harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/NumberFormat.java
    harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/SimpleDateFormat.java

Modified: harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/DateFormatSymbols.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/DateFormatSymbols.java?rev=788016&r1=788015&r2=788016&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/DateFormatSymbols.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/DateFormatSymbols.java
Wed Jun 24 13:32:37 2009
@@ -88,14 +88,7 @@
      *            the locale.
      */
     public DateFormatSymbols(Locale locale) {
-        icuSymbols = new com.ibm.icu.text.DateFormatSymbols(locale);
-        localPatternChars = icuSymbols.getLocalPatternChars();
-        ampms = icuSymbols.getAmPmStrings();
-        eras = icuSymbols.getEras();
-        months = icuSymbols.getMonths();
-        shortMonths = icuSymbols.getShortMonths();
-        shortWeekdays = icuSymbols.getShortWeekdays();
-        weekdays = icuSymbols.getWeekdays();
+        this(locale, new com.ibm.icu.text.DateFormatSymbols(locale));
     }
 
     private void writeObject(ObjectOutputStream oos) throws IOException {
@@ -105,6 +98,19 @@
         oos.defaultWriteObject();
     }
 
+    DateFormatSymbols(Locale locale,
+            com.ibm.icu.text.DateFormatSymbols icuSymbols) {
+
+        this.icuSymbols = icuSymbols;
+        localPatternChars = icuSymbols.getLocalPatternChars();
+        ampms = icuSymbols.getAmPmStrings();
+        eras = icuSymbols.getEras();
+        months = icuSymbols.getMonths();
+        shortMonths = icuSymbols.getShortMonths();
+        shortWeekdays = icuSymbols.getShortWeekdays();
+        weekdays = icuSymbols.getWeekdays();
+    }
+
     @Override
     public Object clone() {
         if (zoneStrings == null) {

Modified: harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/DecimalFormat.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/DecimalFormat.java?rev=788016&r1=788015&r2=788016&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/DecimalFormat.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/DecimalFormat.java
Wed Jun 24 13:32:37 2009
@@ -602,7 +602,7 @@
      */
     public DecimalFormat(String pattern, DecimalFormatSymbols value) {
         symbols = (DecimalFormatSymbols) value.clone();
-        Locale locale = symbols.getLocale(); //$NON-NLS-1$
+        Locale locale = symbols.getLocale();
         icuSymbols = new com.ibm.icu.text.DecimalFormatSymbols(locale);
         copySymbols(icuSymbols, symbols);
 
@@ -614,6 +614,17 @@
         super.setMinimumIntegerDigits(dform.getMinimumIntegerDigits());
     }
 
+    DecimalFormat(String pattern, DecimalFormatSymbols value, com.ibm.icu.text.DecimalFormat
icuFormat) {
+        symbols = value;
+        icuSymbols = value.getIcuSymbols();
+        dform = icuFormat;
+
+        super.setMaximumFractionDigits(dform.getMaximumFractionDigits());
+        super.setMaximumIntegerDigits(dform.getMaximumIntegerDigits());
+        super.setMinimumFractionDigits(dform.getMinimumFractionDigits());
+        super.setMinimumIntegerDigits(dform.getMinimumIntegerDigits());
+    }
+
     /**
      * Changes the pattern of this decimal format to the specified pattern which
      * uses localized pattern characters.
@@ -1425,4 +1436,12 @@
                     }
                 });
     }
+
+    com.ibm.icu.text.DecimalFormat getDform() {
+        return dform;
+    }
+
+    com.ibm.icu.text.DecimalFormatSymbols getIcuSymbols() {
+        return icuSymbols;
+    }
 }

Modified: harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/DecimalFormatSymbols.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/DecimalFormatSymbols.java?rev=788016&r1=788015&r2=788016&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/DecimalFormatSymbols.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/DecimalFormatSymbols.java
Wed Jun 24 13:32:37 2009
@@ -74,15 +74,21 @@
      *            the locale.
      */
     public DecimalFormatSymbols(Locale locale) {
-        com.ibm.icu.text.DecimalFormatSymbols icuSymbols = new com.ibm.icu.text.DecimalFormatSymbols(
-                locale);
+        this(locale, new com.ibm.icu.text.DecimalFormatSymbols(locale));
+    }
+
+    transient private com.ibm.icu.text.DecimalFormatSymbols icuSymbols;
+
+    DecimalFormatSymbols(Locale locale,
+            com.ibm.icu.text.DecimalFormatSymbols icuSymbols) {
+        this.icuSymbols = icuSymbols;
         infinity = icuSymbols.getInfinity();
         NaN = icuSymbols.getNaN();
         this.locale = locale;
         currencySymbol = icuSymbols.getCurrencySymbol();
         intlCurrencySymbol = icuSymbols.getInternationalCurrencySymbol();
         if (locale.getCountry().length() == 0) {
-            currency = Currency.getInstance("XXX");
+            currency = Currency.getInstance("XXX"); //$NON-NLS-1$
         } else {
             currency = Currency.getInstance(locale);
         }
@@ -95,11 +101,12 @@
         patternChars[Percent] = icuSymbols.getPercent();
         patternChars[PerMill] = icuSymbols.getPerMill();
         patternChars[Exponent] = icuSymbols.getExponentSeparator().charAt(0);
-        patternChars[MonetaryDecimalSeparator] = icuSymbols.getMonetaryDecimalSeparator();
+        patternChars[MonetaryDecimalSeparator] = icuSymbols
+                .getMonetaryDecimalSeparator();
         patternChars[MinusSign] = icuSymbols.getMinusSign();
-        
     }
 
+ 
     /**
      * Returns a new {@code DecimalFormatSymbols} with the same symbols as this
      * {@code DecimalFormatSymbols}.
@@ -554,4 +561,8 @@
     Locale getLocale(){
         return locale;
     }
+
+    com.ibm.icu.text.DecimalFormatSymbols getIcuSymbols() {
+        return icuSymbols;
+    }
 }

Modified: harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/NumberFormat.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/NumberFormat.java?rev=788016&r1=788015&r2=788016&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/NumberFormat.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/NumberFormat.java
Wed Jun 24 13:32:37 2009
@@ -494,7 +494,7 @@
         com.ibm.icu.text.DecimalFormat icuFormat = (com.ibm.icu.text.DecimalFormat) com.ibm.icu.text.NumberFormat
                 .getPercentInstance(locale);
         String pattern = icuFormat.toPattern();
-        return new DecimalFormat(pattern, new DecimalFormatSymbols(locale));
+        return new DecimalFormat(pattern, new DecimalFormatSymbols(locale, icuFormat.getDecimalFormatSymbols()),
icuFormat);
     }
 
     @Override

Modified: harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/SimpleDateFormat.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/SimpleDateFormat.java?rev=788016&r1=788015&r2=788016&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/SimpleDateFormat.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/SimpleDateFormat.java
Wed Jun 24 13:32:37 2009
@@ -328,7 +328,7 @@
         this(Locale.getDefault());
         icuFormat = new com.ibm.icu.text.SimpleDateFormat();
         icuFormat.setTimeZone(com.ibm.icu.util.TimeZone.getTimeZone(tzId));
-        pattern = (String)getInternalField("pattern",icuFormat);
+        pattern = (String)getInternalField("pattern", icuFormat); //$NON-NLS-1$
         formatData = new DateFormatSymbols(Locale.getDefault());
     }
 
@@ -482,14 +482,14 @@
         icuFormat = new com.ibm.icu.text.SimpleDateFormat(template, locale);
         icuFormat.setTimeZone(com.ibm.icu.util.TimeZone.getTimeZone(tzId));
         pattern = template;
-        formatData = new DateFormatSymbols(locale);
+        formatData = new DateFormatSymbols(locale, icuFormat.getDateFormatSymbols());
     }
 
     SimpleDateFormat(Locale locale, com.ibm.icu.text.SimpleDateFormat icuFormat){
         this(locale);
         this.icuFormat = icuFormat;
         this.icuFormat.setTimeZone(com.ibm.icu.util.TimeZone.getTimeZone(tzId));
-        pattern = (String)Format.getInternalField("pattern", icuFormat);
+        pattern = (String)Format.getInternalField("pattern", icuFormat); //$NON-NLS-1$
         formatData = new DateFormatSymbols(locale);
     }
     
@@ -527,7 +527,6 @@
      * @throws IllegalArgumentException
      *                if the pattern is invalid.
      */
-    @SuppressWarnings("nls")
     public void applyPattern(String template) {
         validatePattern(template);
         /*



Mime
View raw message