xalan-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dbert...@apache.org
Subject cvs commit: xml-xalan/c/src/XSLT ElemNumber.cpp ElemNumber.hpp
Date Fri, 06 Sep 2002 06:10:33 GMT
dbertoni    2002/09/05 23:10:33

  Modified:    c/src/XSLT ElemNumber.cpp ElemNumber.hpp
  Log:
  Reduced dynamic memory allocation in initialization.
  
  Revision  Changes    Path
  1.58      +59 -73    xml-xalan/c/src/XSLT/ElemNumber.cpp
  
  Index: ElemNumber.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemNumber.cpp,v
  retrieving revision 1.57
  retrieving revision 1.58
  diff -u -r1.57 -r1.58
  --- ElemNumber.cpp	6 Sep 2002 01:39:17 -0000	1.57
  +++ ElemNumber.cpp	6 Sep 2002 06:10:33 -0000	1.58
  @@ -2,7 +2,7 @@
    * The Apache Software License, Version 1.1
    *
    *
  - * Copyright (c) 1999 The Apache Software Foundation.  All rights 
  + * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights 
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -460,9 +460,9 @@
   		{
   			StylesheetExecutionContext::GetAndReleaseCachedString	theMatchPatternString(executionContext);
   
  -			assign(theMatchPatternString.get(), s_piString);
  +			theMatchPatternString.get() = s_piString;
   			append(theMatchPatternString.get(), contextNode->getNodeName());
  -			append(theMatchPatternString.get(), s_leftParenString);
  +			append(theMatchPatternString.get(), XalanUnicode::charRightParenthesis);
   
   			countMatchPattern = executionContext.createMatchPattern(
   					theMatchPatternString.get(),
  @@ -1013,7 +1013,7 @@
   			}
   			else
   			{
  -				theResult += s_defaultSeparatorString;
  +				theResult += XalanUnicode::charFullStop;
   			}
   
   			clear(theIntermediateResult);
  @@ -1328,11 +1328,11 @@
   	switch(numberType)
   	{
   		case XalanUnicode::charLetter_A:
  -			int2alphaCount(listElement, s_alphaCountTable, theResult);
  +			int2alphaCount(listElement, s_alphaCountTable, s_alphaCountTableSize, theResult);
   			break;
   
   		case XalanUnicode::charLetter_a:
  -			int2alphaCount(listElement, s_alphaCountTable, theResult);
  +			int2alphaCount(listElement, s_alphaCountTable, s_alphaCountTableSize, theResult);
   
   			theResult = toLowerCaseASCII(theResult);
   			break;
  @@ -1384,7 +1384,7 @@
   				}
   				else if (equals(letterVal, s_alphabeticString) == true)
   				{
  -					int2alphaCount(listElement, s_elalphaCountTable, theResult);
  +					int2alphaCount(listElement, s_elalphaCountTable, s_elalphaCountTableSize, theResult);
   				}
   				else
   				{
  @@ -1454,13 +1454,14 @@
   
   void
   ElemNumber::int2alphaCount(
  -			int						val,
  -			const XalanDOMString&	table,
  -			XalanDOMString&			theResult)
  +			int							val,
  +			const XalanDOMChar			table[],
  +			XalanDOMString::size_type	length,
  +			XalanDOMString&				theResult)
   {
  -	assert(int(length(table)) == length(table));
  +	assert(int(length) == length);
   
  -	const int	radix = int(length(table));
  +	const int	radix = int(length);
   
   	// Create a buffer to hold the result
   	// TODO:  size of the table can be determined by computing
  @@ -1529,7 +1530,7 @@
   			break;
   
   		// put out the next character of output
  -		buf[charPos--] = charAt(table, lookupIndex);
  +		buf[charPos--] = table[lookupIndex];
   	}
   	while (val > 0);
   
  @@ -1743,8 +1744,10 @@
   }
   
   
  +#define ELEMNUMBER_SIZE(str)	((sizeof(str) / sizeof(str[0]) - 1))
   
  -static const XalanDOMChar	alphaCountTable[] =
  +
  +const XalanDOMChar	ElemNumber::s_alphaCountTable[] =
   {
   	XalanUnicode::charLetter_Z,
   	XalanUnicode::charLetter_A,
  @@ -1775,9 +1778,12 @@
   	0
   };
   
  +const XalanDOMString::size_type		ElemNumber::s_alphaCountTableSize =
  +		ELEMNUMBER_SIZE(s_alphaCountTable);
  +
   
   
  -static const XalanDOMChar	elalphaCountTable[] =
  +const XalanDOMChar	ElemNumber::s_elalphaCountTable[] =
   {
   	0x03c9,
   	0x03b1,
  @@ -1808,8 +1814,9 @@
   };
   
   
  +const XalanDOMString::size_type		ElemNumber::s_elalphaCountTableSize =
  +		ELEMNUMBER_SIZE(s_elalphaCountTable);
   
  -static XalanDOMString								s_atString;
   
   static XalanDOMString								s_textString;
   
  @@ -1817,20 +1824,6 @@
   
   static XalanDOMString								s_slashString;
   
  -static XalanDOMString								s_piString;
  -
  -static XalanDOMString								s_leftParenString;
  -
  -static XalanDOMString								s_dotString;
  -
  -static XalanDOMString								s_oneString;
  -
  -static XalanDOMString								s_defaultSeparatorString;
  -
  -static XalanDOMString								s_alphaCountTable;
  -
  -static XalanDOMString								s_elalphaCountTable;
  -
   
   
   static ElemNumber::DecimalToRomanVectorType			s_romanConvertTable;
  @@ -1838,7 +1831,11 @@
   static ElemNumber::NumberingResourceBundleMapType	s_resourceBundles;
   
   
  -const XalanDOMString&	ElemNumber::s_atString = ::s_atString;
  +const XalanDOMChar		ElemNumber::s_atString[] =
  +{
  +	XalanUnicode::charAmpersand,
  +	0
  +};
   
   const XalanDOMString&	ElemNumber::s_textString = ::s_textString;
   
  @@ -1846,19 +1843,33 @@
   
   const XalanDOMString&	ElemNumber::s_slashString = ::s_slashString;
   
  -const XalanDOMString&	ElemNumber::s_piString = ::s_piString;
  -
  -const XalanDOMString&	ElemNumber::s_leftParenString = ::s_leftParenString;
  -
  -const XalanDOMString&	ElemNumber::s_dotString = ::s_dotString;
  -
  -const XalanDOMString&	ElemNumber::s_oneString = ::s_oneString;
  -
  -const XalanDOMString&	ElemNumber::s_defaultSeparatorString = ::s_defaultSeparatorString;
  -
  -const XalanDOMString&	ElemNumber::s_alphaCountTable = ::s_alphaCountTable;
  -
  -const XalanDOMString&	ElemNumber::s_elalphaCountTable = ::s_elalphaCountTable;
  +const XalanDOMChar		ElemNumber::s_piString[] =
  +{
  +	XalanUnicode::charLetter_p,
  +	XalanUnicode::charLetter_r,
  +	XalanUnicode::charLetter_o,
  +	XalanUnicode::charLetter_c,
  +	XalanUnicode::charLetter_e,
  +	XalanUnicode::charLetter_s,
  +	XalanUnicode::charLetter_s,
  +	XalanUnicode::charLetter_i,
  +	XalanUnicode::charLetter_n,
  +	XalanUnicode::charLetter_g,
  +	XalanUnicode::charHyphenMinus,
  +	XalanUnicode::charLetter_i,
  +	XalanUnicode::charLetter_n,
  +	XalanUnicode::charLetter_s,
  +	XalanUnicode::charLetter_t,
  +	XalanUnicode::charLetter_r,
  +	XalanUnicode::charLetter_u,
  +	XalanUnicode::charLetter_c,
  +	XalanUnicode::charLetter_t,
  +	XalanUnicode::charLetter_i,
  +	XalanUnicode::charLetter_o,
  +	XalanUnicode::charLetter_n,
  +	XalanUnicode::charLeftParenthesis,
  +	0
  +};
   
   const XalanDOMChar		ElemNumber::s_levelString[] =
   {
  @@ -2022,7 +2033,8 @@
   
   	const XalanDOMString	theLanguageString("el");
   
  -	const XalanNumberingResourceBundle	theElaphaBundle(
  +	// Create an instance...
  +	XalanNumberingResourceBundle	theElaphaBundle(
   		theLanguageString,
   		theLanguageString,
   		theLanguageString,
  @@ -2039,9 +2051,8 @@
   		theElalphaDigitsTable,
   		theDigitsTableTable);
   
  -	typedef ElemNumber::NumberingResourceBundleMapType::value_type	value_type;
  -
  -	theBundleMap[elalphaNumberType] = theElaphaBundle;
  +	// Swap it with the one in the map (this avoids making a copy...)
  +	theBundleMap[elalphaNumberType].swap(theElaphaBundle);
   }
   
   
  @@ -2049,28 +2060,12 @@
   void
   ElemNumber::initialize()
   {
  -	::s_atString = XALAN_STATIC_UCODE_STRING("@");
  -
   	::s_textString = XALAN_STATIC_UCODE_STRING("text()");
   
   	::s_commentString = XALAN_STATIC_UCODE_STRING("comment()");
   
   	::s_slashString = XALAN_STATIC_UCODE_STRING("/");
   
  -	::s_piString = XALAN_STATIC_UCODE_STRING("pi(");
  -
  -	::s_leftParenString = XALAN_STATIC_UCODE_STRING(")");
  -
  -	::s_dotString = XALAN_STATIC_UCODE_STRING(".");
  -
  -	::s_oneString = XALAN_STATIC_UCODE_STRING("1");
  -
  -	::s_defaultSeparatorString = XALAN_STATIC_UCODE_STRING(".");
  -
  -	::s_alphaCountTable = alphaCountTable;
  -
  -	::s_elalphaCountTable = elalphaCountTable;
  -
   	::s_romanConvertTable.reserve(7);
   
   	::s_romanConvertTable.push_back(
  @@ -2130,18 +2125,9 @@
   void
   ElemNumber::terminate()
   {
  -	releaseMemory(::s_atString);
   	releaseMemory(::s_textString);
   	releaseMemory(::s_commentString);
   	releaseMemory(::s_slashString);
  -	releaseMemory(::s_piString);
  -	releaseMemory(::s_leftParenString);
  -	releaseMemory(::s_dotString);
  -	releaseMemory(::s_oneString);
  -	releaseMemory(::s_defaultSeparatorString);
  -
  -	releaseMemory(::s_alphaCountTable);
  -	releaseMemory(::s_elalphaCountTable);
   
   	DecimalToRomanVectorType().swap(::s_romanConvertTable);
   
  
  
  
  1.37      +15 -30    xml-xalan/c/src/XSLT/ElemNumber.hpp
  
  Index: ElemNumber.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemNumber.hpp,v
  retrieving revision 1.36
  retrieving revision 1.37
  diff -u -r1.36 -r1.37
  --- ElemNumber.hpp	6 Sep 2002 03:02:37 -0000	1.36
  +++ ElemNumber.hpp	6 Sep 2002 06:10:33 -0000	1.37
  @@ -2,7 +2,7 @@
    * The Apache Software License, Version 1.1
    *
    *
  - * Copyright (c) 1999 The Apache Software Foundation.  All rights 
  + * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights 
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -297,6 +297,7 @@
   	 * count using the sequence A B C ... Z AA AB AC.... etc.
   	 * @param val Value to convert -- must be greater than zero.
   	 * @param table a table containing one character for each digit in the radix
  +	 * @param length the table length
   	 * @param result returns the stringrepresenting alpha count of number.
   	 * @see XSLTEngineImpl#DecimalToRoman
   	 * 
  @@ -305,9 +306,10 @@
   	 */
   	static void
   	int2alphaCount(
  -			int						val,
  -			const XalanDOMString&	table,
  -			XalanDOMString&			theResult);
  +			int							val,
  +			const XalanDOMChar			table[],
  +			XalanDOMString::size_type	length,
  +			XalanDOMString&				theResult);
   
   	/**
   	 * Convert a long integer into traditional alphabetic counting, in other words
  @@ -396,7 +398,7 @@
   	/**
    	 * The string "@".
    	 */
  - 	static const XalanDOMString&			s_atString;
  + 	static const XalanDOMChar				s_atString[];
   
   		/**
    	 * The string "text()".
  @@ -414,29 +416,9 @@
    	static const XalanDOMString&			s_slashString;
   
   	/**
  - 	 * The string "pi(".
  - 	 */
  - 	static const XalanDOMString&			s_piString;
  -
  -	/**
  - 	 * The string ")".
  - 	 */
  - 	static const XalanDOMString&			s_leftParenString;
  -
  -	/**
  - 	 * The string ".".
  + 	 * The string "processing-instruction(".
    	 */
  - 	static const XalanDOMString&			s_dotString;
  -
  -	/**
  - 	 * The string "1".
  - 	 */
  - 	static const XalanDOMString&			s_oneString;
  -
  -	/**
  - 	 * The string ".".
  - 	 */
  - 	static const XalanDOMString&			s_defaultSeparatorString;
  + 	static const XalanDOMChar				s_piString[];
   
   	/**
    	 * The string "level".
  @@ -470,11 +452,14 @@
   
   	/**
   	* Chars for converting integers into alpha counts.
  -	* @see XSLTEngineImpl#int2alphaCount
   	*/
  -	static const XalanDOMString&			s_alphaCountTable;
  +	static const XalanDOMChar				s_alphaCountTable[];
  +
  +	static const XalanDOMString::size_type	s_alphaCountTableSize;
  +
  +	static const XalanDOMChar				s_elalphaCountTable[];
   
  -	static const XalanDOMString&			s_elalphaCountTable;
  +	static const XalanDOMString::size_type	s_elalphaCountTableSize;
   
   	/**
   	 * Table to help in converting decimals to roman numerals.
  
  
  

---------------------------------------------------------------------
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