ytalwar     2005/04/01 11:28:08

  Modified:    java/src/org/apache/xalan/templates ElemNumber.java
  Log:
  This is a fix for XALANJ-2089.
  Christine Li has created this patch.
  Brian Minchau helped in creating this patch.
  Brian Minchau also reviewed this patch.
  
  org.apache.xalan.templates.ElemNumber.java has raised some performance issue 
as 
  a static array to hold resources was removed earlier.  However, the removal 
of static array is necessary
  to fix a potential bug multithread environment, where a given thread can 
request different locale than another thread.
  
  This patch resolves the performance glicth that was found in internal testing.
  
  Revision  Changes    Path
  1.37      +21 -17    
xml-xalan/java/src/org/apache/xalan/templates/ElemNumber.java
  
  Index: ElemNumber.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/templates/ElemNumber.java,v
  retrieving revision 1.36
  retrieving revision 1.37
  diff -u -r1.36 -r1.37
  --- ElemNumber.java   4 Feb 2005 18:08:57 -0000       1.36
  +++ ElemNumber.java   1 Apr 2005 19:28:07 -0000       1.37
  @@ -74,6 +74,12 @@
   {
       static final long serialVersionUID = 8118472298274407610L;
   
  +    /**
  +     * Chars for converting integers into alpha counts.
  +     * @see TransformerImpl#int2alphaCount
  +     */
  +    private CharArrayWrapper m_alphaCountTable = null;
  +    
       private class MyPrefixResolver implements PrefixResolver {
           
           DTM dtm;
  @@ -1334,28 +1340,26 @@
       switch (numberType)
       {
       case 'A' :
  -
  -        thisBundle =
  -          (XResourceBundle) XResourceBundle.loadResourceBundle(
  -            org.apache.xml.utils.res.XResourceBundle.LANG_BUNDLE_NAME, 
getLocale(transformer, contextNode));
  -
  -
  -        alphaCountTable = (CharArrayWrapper) 
thisBundle.getObject(org.apache.xml.utils.res.XResourceBundle.LANG_ALPHABET);
  -
  -      int2alphaCount(listElement, alphaCountTable, formattedNumber);
  +        if (null == m_alphaCountTable){
  +                thisBundle =
  +                  (XResourceBundle) XResourceBundle.loadResourceBundle(
  +                    
org.apache.xml.utils.res.XResourceBundle.LANG_BUNDLE_NAME, 
getLocale(transformer, contextNode));
  +                m_alphaCountTable = (CharArrayWrapper) 
thisBundle.getObject(org.apache.xml.utils.res.XResourceBundle.LANG_ALPHABET);   
             
  +        }
  +      int2alphaCount(listElement, m_alphaCountTable, formattedNumber);
         break;
       case 'a' :
  -
  -        thisBundle =
  -          (XResourceBundle) XResourceBundle.loadResourceBundle(
  -            org.apache.xml.utils.res.XResourceBundle.LANG_BUNDLE_NAME, 
getLocale(transformer, contextNode));
  -
  -        alphaCountTable = (CharArrayWrapper) 
thisBundle.getObject(org.apache.xml.utils.res.XResourceBundle.LANG_ALPHABET);
  +        if (null == m_alphaCountTable){
  +                thisBundle =
  +                  (XResourceBundle) XResourceBundle.loadResourceBundle(
  +                    
org.apache.xml.utils.res.XResourceBundle.LANG_BUNDLE_NAME, 
getLocale(transformer, contextNode));
  +                m_alphaCountTable = (CharArrayWrapper) 
thisBundle.getObject(org.apache.xml.utils.res.XResourceBundle.LANG_ALPHABET);   
             
  +        }
         FastStringBuffer stringBuf = StringBufferPool.get();
   
         try
         {
  -        int2alphaCount(listElement, alphaCountTable, stringBuf);
  +        int2alphaCount(listElement, m_alphaCountTable, stringBuf);
           formattedNumber.append(
             stringBuf.toString().toLowerCase(
               getLocale(transformer, contextNode)));
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to