xalan-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zong...@apache.org
Subject svn commit: r524810 - /xalan/java/trunk/src/org/apache/xpath/compiler/Lexer.java
Date Mon, 02 Apr 2007 15:51:56 GMT
Author: zongaro
Date: Mon Apr  2 08:51:55 2007
New Revision: 524810

URL: http://svn.apache.org/viewvc?view=rev&rev=524810
Log:
Part of fix for Jira issue XALANJ-2375.

Lexer.tokenize was always creating an OpMapVector object with large initial
sizes.  This was wasteful, because each XPath expression so tokenize might
need only a small amount of space.  Instead, changed the initial size to be
equal to five times the length of the string to be tokenized, just as a
very conservative estimate.  This has a significant impact on the performance
of the XPath API.

Reviewed by Christine Li (jycli () ca ! ibm ! com).

Modified:
    xalan/java/trunk/src/org/apache/xpath/compiler/Lexer.java

Modified: xalan/java/trunk/src/org/apache/xpath/compiler/Lexer.java
URL: http://svn.apache.org/viewvc/xalan/java/trunk/src/org/apache/xpath/compiler/Lexer.java?view=diff&rev=524810&r1=524809&r2=524810
==============================================================================
--- xalan/java/trunk/src/org/apache/xpath/compiler/Lexer.java (original)
+++ xalan/java/trunk/src/org/apache/xpath/compiler/Lexer.java Mon Apr  2 08:51:55 2007
@@ -113,8 +113,15 @@
     m_compiler.m_currentPattern = pat;
     m_patternMapSize = 0; 
 
-    // This needs to grow too.
-    m_compiler.m_opMap = new OpMapVector(OpMap.MAXTOKENQUEUESIZE * 5, OpMap.BLOCKTOKENQUEUESIZE
* 5, OpMap.MAPINDEX_LENGTH);
+    // This needs to grow too.  Use a conservative estimate that the OpMapVector
+    // needs about five time the length of the input path expression - to a
+    // maximum of MAXTOKENQUEUESIZE*5.  If the OpMapVector needs to grow, grow
+    // it freely (second argument to constructor).
+    int initTokQueueSize = ((pat.length() < OpMap.MAXTOKENQUEUESIZE)
+                                 ? pat.length() :  OpMap.MAXTOKENQUEUESIZE) * 5;
+    m_compiler.m_opMap = new OpMapVector(initTokQueueSize,
+                                         OpMap.BLOCKTOKENQUEUESIZE * 5,
+                                         OpMap.MAPINDEX_LENGTH);
 
     int nChars = pat.length();
     int startSubstring = -1; 



---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org


Mime
View raw message