logo       
Google Custom Search
    AddThis Social Bookmark Button
-->

Little optimization of JCEMapper: msg#00082

Subject: Little optimization of JCEMapper
Hi,
   Profiling a program that uses the xmlsec library I see that a vast
amount of time is waste in  translateURItoJCEID (in 86 times called a
4sec of 22 sec that the whole program time).
I made a little cache in order to not parse and xpath search the
config.xml node in order to find the provider again and again. With this
4 line change the total time spend in the function decrease to 200ms.

Perhaps can help somebody.

Regards,

Index: JCEMapper.java
===================================================================
RCS file:
/home/cvspublic/xml-security/src/org/apache/xml/security/algorithms/JCEMapper.java,v
retrieving revision 1.19
diff -u -r1.19 JCEMapper.java

--- JCEMapper.java    6 Mar 2004 11:39:49 -0000    1.19
+++ JCEMapper.java    13 Apr 2004 17:38:04 -0000
@@ -21,6 +21,8 @@
import java.security.Key;
import java.security.Provider;
import java.security.Security;
+import java.util.HashMap;
+import java.util.Map;

import javax.xml.transform.TransformerException;

@@ -48,6 +50,8 @@

   /** Field _nscontext */
   private static Element _nscontext = null;
+
+   private static Map uriToProvider = new HashMap();

   /**
    * Method init
@@ -179,7 +183,10 @@
      log.debug("Request for URI " + AlgorithmURI);

      try {
-
+          ProviderIdClass prov=(ProviderIdClass)
uriToProvider.get(AlgorithmURI);
+          if (prov!=null) {
+              return prov;
+          }
         /*
         Attr jceName = (Attr) XPathAPI.selectSingleNode(
            JCEMapper._providerList,
@@ -204,7 +211,7 @@

               log.debug("Found " + result.getAlgorithmID() + " from
provider "
                         + result.getProviderId());
-
+               uriToProvider.put(AlgorithmURI,result);
               return result;
            }
         }





<Prev in Thread] Current Thread [Next in Thread>