You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by db...@apache.org on 2002/10/11 03:59:02 UTC

cvs commit: xml-xalan/c/src/XPath XalanQName.cpp XalanQName.hpp

dbertoni    2002/10/10 18:59:02

  Modified:    c/src/XPath XalanQName.cpp XalanQName.hpp
  Log:
  Temporary enhancements until the final removal of stack searching.
  
  Revision  Changes    Path
  1.5       +74 -48    xml-xalan/c/src/XPath/XalanQName.cpp
  
  Index: XalanQName.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XPath/XalanQName.cpp,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- XalanQName.cpp	2 Apr 2002 06:11:31 -0000	1.4
  +++ XalanQName.cpp	11 Oct 2002 01:59:02 -0000	1.5
  @@ -79,8 +79,7 @@
   const XalanDOMString*
   XalanQName::getNamespaceForPrefix(
   			const NamespaceVectorType&	namespaces,
  -			const XalanDOMString&		prefix,
  -			bool						reverse)
  +			const XalanDOMString&		prefix)
   {
   	const XalanDOMString*	nsURI = 0;
   
  @@ -96,36 +95,17 @@
   	{
   		const NamespaceVectorType::size_type	theSize = namespaces.size();
   
  -		if (reverse)
  +		for(NamespaceVectorType::size_type j = theSize; j > 0; --j)
   		{
  -			for(NamespaceVectorType::size_type j = theSize; j > 0; --j)
  -			{
  -				const NameSpace&	ns = namespaces[j - 1];
  -
  -				const XalanDOMString&	thisPrefix = ns.getPrefix();
  +			const NameSpace&	ns = namespaces[j - 1];
   
  -				if(::equals(prefix, thisPrefix))
  -				{
  -					nsURI = &ns.getURI();
  +			const XalanDOMString&	thisPrefix = ns.getPrefix();
   
  -					break;
  -				}
  -			}
  -		}
  -		else
  -		{
  -			for(NamespaceVectorType::size_type j = 0; j < theSize; j++)
  +			if(::equals(prefix, thisPrefix))
   			{
  -				const NameSpace&	ns = namespaces[j];
  -
  -				const XalanDOMString&	thisPrefix = ns.getPrefix();
  -
  -				if(::equals(prefix, thisPrefix))
  -				{
  -					nsURI = &ns.getURI();
  +				nsURI = &ns.getURI();
   
  -					break;
  -				}
  +				break;
   			}
   		}
   	}
  @@ -138,22 +118,51 @@
   const XalanDOMString*
   XalanQName::getNamespaceForPrefix(
   			const NamespacesStackType&	nsStack,
  -			const XalanDOMString&		prefix,
  -			bool						reverse)
  +			const XalanDOMString&		prefix)
   {
  +#if 1
  +	return getNamespaceForPrefix(nsStack.begin(), nsStack.end(), prefix);
  +#else
   	const XalanDOMString*	nsURI = 0;
   
   	for(NamespacesStackType::size_type i = nsStack.size(); i > 0; --i)
   	{
   		const NamespaceVectorType&	namespaces = nsStack[i - 1];
   
  -		nsURI = getNamespaceForPrefix(namespaces, prefix, reverse);
  +		nsURI = getNamespaceForPrefix(namespaces, prefix);
   
   		if (nsURI != 0)
   			break;
   	}
   
   	return nsURI;
  +#endif
  +}
  +
  +
  +
  +const XalanDOMString*
  +XalanQName::getNamespaceForPrefix(
  +			NamespacesStackType::const_iterator		theBegin,
  +			NamespacesStackType::const_iterator		theEnd,
  +			const XalanDOMString&					prefix)
  +{
  +	const XalanDOMString*	nsURI = 0;
  +
  +	if (theBegin != theEnd)
  +	{
  +		do
  +		{
  +			nsURI = getNamespaceForPrefix(*(--theEnd), prefix);
  +
  +			if (nsURI != 0)
  +			{
  +				break;
  +			}
  +		} while(theBegin != theEnd);
  +	}
  +
  +	return nsURI;
   }
   
   
  @@ -161,12 +170,13 @@
   const XalanDOMString*
   XalanQName::getPrefixForNamespace(
   			const NamespaceVectorType&	namespaces,
  -			const XalanDOMString&		uri,
  -			bool						/* reverse */)
  +			const XalanDOMString&		uri)
   {
   	const XalanDOMString*	thePrefix = 0;
   
  -	for(NamespaceVectorType::size_type j = namespaces.size(); j > 0; --j)
  +	const NamespaceVectorType::size_type	theSize = namespaces.size();
  +
  +	for(NamespaceVectorType::size_type j = theSize; j > 0; --j)
   	{
   		const NameSpace&		ns = namespaces[j - 1];
   		const XalanDOMString&	thisURI = ns.getURI();
  @@ -187,36 +197,52 @@
   const XalanDOMString*
   XalanQName::getPrefixForNamespace(
   			const NamespacesStackType&	nsStack,
  -			const XalanDOMString&		uri,
  -			bool						reverse)
  +			const XalanDOMString&		uri)
   {
  +#if 1
  +	return getPrefixForNamespace(nsStack.begin(), nsStack.end(), uri);
  +#else
   	const XalanDOMString*					thePrefix = 0;
   
   	const NamespacesStackType::size_type	depth = nsStack.size();
   
  -	if (reverse)
  +	for(NamespacesStackType::size_type i = depth; i > 0; --i)
   	{
  -		for(NamespacesStackType::size_type i = depth; i > 0; --i)
  -		{
  -			const NamespaceVectorType&	namespaces = nsStack[i - 1];
  +		const NamespaceVectorType&	namespaces = nsStack[i - 1];
   
  -			thePrefix = getPrefixForNamespace(namespaces, uri, reverse);
  +		thePrefix = getPrefixForNamespace(namespaces, uri);
   
  -			if (thePrefix != 0)
  -				break;
  +		if (thePrefix != 0)
  +		{
  +			break;
   		}
   	}
  -	else
  +
  +	return thePrefix;
  +#endif
  +}
  +
  +
  +
  +const XalanDOMString*
  +XalanQName::getPrefixForNamespace(
  +			NamespacesStackType::const_iterator		theBegin,
  +			NamespacesStackType::const_iterator		theEnd,
  +			const XalanDOMString&					uri)
  +{
  +	const XalanDOMString*	thePrefix = 0;
  +
  +	if (theBegin != theEnd)
   	{
  -		for(NamespacesStackType::size_type i = 0; i < depth; i++)
  +		do
   		{
  -			const NamespaceVectorType&	namespaces = nsStack[i];
  -
  -			thePrefix = getPrefixForNamespace(namespaces, uri, reverse);
  +			thePrefix = getPrefixForNamespace(*(--theEnd), uri);
   
   			if (thePrefix != 0)
  +			{
   				break;
  -		}
  +			}
  +		} while(theBegin != theEnd);
   	}
   
   	return thePrefix;
  
  
  
  1.5       +38 -13    xml-xalan/c/src/XPath/XalanQName.hpp
  
  Index: XalanQName.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XPath/XalanQName.hpp,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- XalanQName.hpp	6 May 2002 05:26:59 -0000	1.4
  +++ XalanQName.hpp	11 Oct 2002 01:59:02 -0000	1.5
  @@ -179,33 +179,45 @@
   	}
   
   	/**
  -	 * Get the namespace from a prefix by searching a vector of namespaces.
  +	 * Get the namespace for a prefix by searching a vector of namespaces.
   	 *
   	 * @param namespaces vector of namespaces to search
   	 * @param prefix     namespace prefix to find
  -	 * @param reverse    true to search vector from last to first, default true
   	 * @return pointer to the string value if found, otherwise null.
   	 */
   	static const XalanDOMString*
   	getNamespaceForPrefix(
   			const NamespaceVectorType&	namespaces,
  -			const XalanDOMString&		prefix,
  -			bool						reverse = true);
  +			const XalanDOMString&		prefix);
   
   	/**
  -	 * Get the namespace from a prefix by searching a stack of namespace
  +	 * Get the namespace for a prefix by searching a stack of namespace
   	 * vectors.
   	 *
   	 * @param nsStack stack of namespace vectors to search
   	 * @param prefix  namespace prefix to find
  -	 * @param reverse true to search vector from last to first, default true
   	 * @return pointer to the string value if found, otherwise null.
   	 */
   	static const XalanDOMString*
   	getNamespaceForPrefix(
   			const NamespacesStackType&	nsStack,
  -			const XalanDOMString&		prefix,
  -			bool						reverse = true);
  +			const XalanDOMString&		prefix);
  +
  +	/**
  +	 * Get the namespace for a prefix by searching a range of iterators.
  +	 * The search is done in reverse, from the end of the range to the
  +	 * beginning.
  +	 *
  +	 * @param theBegin The beginning iterator for the range
  +	 * @param theBegin The ending iterator for the range
  +	 * @param prefix  namespace prefix to find
  +	 * @return pointer to the string value if found, otherwise null.
  +	 */
  +	static const XalanDOMString*
  +	getNamespaceForPrefix(
  +			NamespacesStackType::const_iterator		theBegin,
  +			NamespacesStackType::const_iterator		theEnd,
  +			const XalanDOMString&					prefix);
   
   	/**
   	 * Get the prefix for a namespace by searching a vector of namespaces.
  @@ -218,8 +230,7 @@
   	static const XalanDOMString*
   	getPrefixForNamespace(
   			const NamespaceVectorType&	namespaces,
  -			const XalanDOMString&		uri,
  -			bool						reverse = true);
  +			const XalanDOMString&		uri);
   
   	/**
   	 * Get the prefix for a namespace by searching a stack of namespace
  @@ -227,14 +238,28 @@
   	 *
   	 * @param nsStack stack of namespace vectors to search
   	 * @param uri     URI string for namespace to find
  -	 * @param reverse true to search vector from last to first, default true
   	 * @return pointer to the string value if found, otherwise null.
   	 */
   	static const XalanDOMString*
   	getPrefixForNamespace(
   			const NamespacesStackType&	nsStack,
  -			const XalanDOMString&		uri,
  -			bool						reverse = true);
  +			const XalanDOMString&		uri);
  +
  +	/**
  +	 * Get the prefix for a namespace by searching a range of iterators.
  +	 * The search is done in reverse, from the end of the range to the
  +	 * beginning.
  +	 *
  +	 * @param theBegin The beginning iterator for the range to search
  +	 * @param theBegin The ending iterator for the range to search
  +	 * @param uri     URI string for namespace to find
  +	 * @return pointer to the string value if found, otherwise null.
  +	 */
  +	static const XalanDOMString*
  +	getPrefixForNamespace(
  +			NamespacesStackType::const_iterator		theBegin,
  +			NamespacesStackType::const_iterator		theEnd,
  +			const XalanDOMString&					uri);
   
   	/**
   	 * Determine if the string supplied satisfies the grammar for
  
  
  

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