dbertoni    2003/05/08 11:13:22

  Modified:    c/src/XPath XPathExpression.cpp XPathExpression.hpp
                        XPathProcessorImpl.cpp XPathProcessorImpl.hpp
  Log:
  Removed obsolete pattern map code.
  
  Revision  Changes    Path
  1.46      +0 -8      xml-xalan/c/src/XPath/XPathExpression.cpp
  
  Index: XPathExpression.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XPath/XPathExpression.cpp,v
  retrieving revision 1.45
  retrieving revision 1.46
  diff -u -r1.45 -r1.46
  --- XPathExpression.cpp       5 Mar 2003 04:41:11 -0000       1.45
  +++ XPathExpression.cpp       8 May 2003 18:13:21 -0000       1.46
  @@ -369,7 +369,6 @@
        m_lastOpCodeIndex(0),
        m_tokenQueue(),
        m_currentPosition(0),
  -     m_patternMap(100, 0),
        m_currentPattern()
   {
        m_opMap.reserve(eDefaultOpMapSize);
  @@ -393,8 +392,6 @@
   
        m_opMap.clear();
        m_tokenQueue.clear();
  -
  -     fill(m_patternMap.begin(), m_patternMap.end(), 0);
   }
   
   
  @@ -405,11 +402,6 @@
        if (m_opMap.capacity() > m_opMap.size())
        {
                OpCodeMapType(m_opMap).swap(m_opMap);
  -     }
  -
  -     if (m_patternMap.capacity() > m_patternMap.size())
  -     {
  -             PatternMapType(m_patternMap).swap(m_patternMap);
        }
   }
   
  
  
  
  1.36      +0 -129    xml-xalan/c/src/XPath/XPathExpression.hpp
  
  Index: XPathExpression.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XPath/XPathExpression.hpp,v
  retrieving revision 1.35
  retrieving revision 1.36
  diff -u -r1.35 -r1.36
  --- XPathExpression.hpp       5 Mar 2003 04:41:11 -0000       1.35
  +++ XPathExpression.hpp       8 May 2003 18:13:21 -0000       1.36
  @@ -740,7 +740,6 @@
   
        typedef vector<int>                                             
OpCodeMapType;
        typedef vector<XToken>                                  TokenQueueType;
  -     typedef vector<int>                                             
PatternMapType;
   
        typedef OpCodeMapType::value_type               OpCodeMapValueType;
        typedef OpCodeMapType::size_type                OpCodeMapSizeType;
  @@ -752,7 +751,6 @@
   
        typedef std::vector<int>                                OpCodeMapType;
        typedef std::vector<XToken>                             TokenQueueType;
  -     typedef std::vector<int>                                PatternMapType;
   
        typedef OpCodeMapType::value_type               OpCodeMapValueType;
        typedef OpCodeMapType::size_type                OpCodeMapSizeType;
  @@ -764,8 +762,6 @@
   
        typedef TokenQueueType::value_type              TokenQueueValueType;
        typedef TokenQueueType::size_type               TokenQueueSizeType;
  -     typedef PatternMapType::value_type              PatternMapValueType;
  -     typedef PatternMapType::size_type               PatternMapSizeType;
   
        /**
         * The length is always the opcode position + 1. Length is always 
expressed
  @@ -852,17 +848,6 @@
        }
   
        /**
  -      * Retrieve number of elements in the pattern map.
  -      * 
  -      * @return size of pattern map
  -      */
  -     PatternMapSizeType
  -     patternMapSize() const
  -     {
  -             return m_patternMap.size();
  -     }
  -
  -     /**
         * Retrieve the value of an operation code at a specified position in 
the
         * list.
         * 
  @@ -1213,7 +1198,6 @@
                m_tokenQueue.insert(m_tokenQueue.begin() + (m_currentPosition - 
1), XToken(theToken));
        }
   
  -#if 1
        /**
         * Replace a token in the token queue.
         * 
  @@ -1235,55 +1219,8 @@
   
                m_tokenQueue[thePosition] = theToken;
        }
  -#else
  -     /**
  -      * Replace a token in the token queue.
  -      * 
  -      * @param theOffset the offset at which to replace the token.
  -      * @param theToken string value for the new token
  -      */
  -     void
  -     replaceRelativeToken(
  -                     int                                             
theOffset,
  -                     const XalanDOMString&   theToken)
  -     {
  -             assert(c_wstr(theToken) != 0);
  -
  -             const int       thePosition = int(m_currentPosition) + 
theOffset;
  -
  -             if (thePosition < 0 ||
  -                     thePosition >= int(tokenQueueSize()))
  -             {
  -                     throw InvalidRelativeTokenPosition(theOffset);
  -             }
  -
  -             m_tokenQueue[thePosition] = theToken;
  -     }
   
        /**
  -      * Replace a token in the token queue.
  -      * 
  -      * @param theOffset the offset at which to replace the token.
  -      * @param theToken double value for the new token
  -      */
  -     void
  -     replaceRelativeToken(
  -                     int             theOffset,
  -                     double  theToken)
  -     {
  -             assert(theToken != 0);
  -
  -             const int       thePosition = int(m_currentPosition) + 
theOffset;
  -
  -             if (thePosition < 0 || thePosition >= int(tokenQueueSize()))
  -             {
  -                     throw InvalidRelativeTokenPosition(theOffset);
  -             }
  -
  -             m_tokenQueue[thePosition] = theToken;
  -     }
  -#endif
  -     /**
         * Diagnostic function to output the operation code map.
         * 
         * @param thePrintWriter   output device
  @@ -1416,61 +1353,6 @@
        pushCurrentTokenOnOpCodeMap();
   
        /**
  -      * Retrieve a pattern in the pattern map at the specified position.
  -      * position in the token queue.
  -      * 
  -      * @param thePatternPosition position in pattern map
  -      * @return match pattern
  -      */
  -     PatternMapValueType
  -     getPattern(int  thePatternPosition) const
  -     {
  -             assert(int(patternMapSize()) > thePatternPosition);
  -
  -             return m_patternMap[thePatternPosition];
  -     }
  -
  -     /**
  -      * Retrieve a pattern in the pattern map at the specified position.
  -      * position in the token queue.
  -      * 
  -      * @param thePatternPosition position in pattern map
  -      * @return match pattern
  -      */
  -     PatternMapValueType
  -     getPattern(PatternMapSizeType   thePatternPosition) const
  -     {
  -             assert(patternMapSize() > thePatternPosition);
  -
  -             return m_patternMap[thePatternPosition];
  -     }
  -
  -     /**
  -      * Push a pattern onto the pattern map.
  -      *
  -      * @param thePattern match pattern to push
  -      */
  -     void
  -     pushPattern(PatternMapValueType thePattern)
  -     {
  -             m_patternMap.push_back(thePattern);
  -     }
  -
  -     /**
  -      * Adjust the value of a pattern at a specified index in the pattern 
map.
  -      *
  -      * @param theIndex      index in map
  -      * @param theAdjustment value of adjustment to add
  -      */
  -     void
  -     adjustPattern(
  -                     OpCodeMapSizeType       theIndex,
  -                     PatternMapValueType     theAdjustment)
  -     {
  -             m_patternMap[theIndex] += theAdjustment;
  -     }
  -
  -     /**
         * Change the current pattern in the pattern map.
         *
         * @param thePattern match pattern to make current
  @@ -1519,16 +1401,6 @@
        TokenQueueSizeType              m_currentPosition;
   
        /**
  -      * This holds a map to the m_tokenQueue that tells where the top-level
  -      * elements are. It is used for pattern matching so the m_tokenQueue 
can be
  -      * walked backwards. Each element that is a 'target', (right-most top 
level
  -      * element name) has TARGETEXTRA added to it.
  -      * 
  -      */
  -      // Ignore this, it is going away.
  -     PatternMapType                  m_patternMap;
  -
  -     /**
         * The current pattern string, for diagnostics purposes.
         */
        XalanDOMString                  m_currentPattern;
  @@ -1540,7 +1412,6 @@
        {
                eDefaultOpMapSize = 100,
                eDefaultTokenQueueSize = 50,
  -             eDefaultPatternMapSize = 100
        };
   
        NumberLiteralValueVectorType    m_numberLiteralValues;
  
  
  
  1.72      +8 -103    xml-xalan/c/src/XPath/XPathProcessorImpl.cpp
  
  Index: XPathProcessorImpl.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XPath/XPathProcessorImpl.cpp,v
  retrieving revision 1.71
  retrieving revision 1.72
  diff -u -r1.71 -r1.72
  --- XPathProcessorImpl.cpp    11 Feb 2003 03:07:15 -0000      1.71
  +++ XPathProcessorImpl.cpp    8 May 2003 18:13:21 -0000       1.72
  @@ -2,7 +2,7 @@
    * The Apache Software License, Version 1.1
    *
    *
  - * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights 
  + * Copyright (c) 1999-2003 The Apache Software Foundation.  All rights 
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -224,13 +224,6 @@
        int             startSubstring = -1;
        int             posOfNSSep = -1;
   
  -     bool            isStartOfPat = true;
  -     bool            isAttrName = false;
  -
  -     // Nesting of '[' so we can know if the given element should be 
  -     // counted inside the m_patternMap.
  -     int nesting = 0;
  -
        const XPathConstructionContext::GetAndReleaseCachedString       
theGuard(*m_constructionContext);
   
        XalanDOMString&         theToken = theGuard.get();
  @@ -245,10 +238,6 @@
                        {
                                if(startSubstring != -1)
                                {
  -                                     isStartOfPat = 
mapPatternElemPos(nesting, isStartOfPat, isAttrName);
  -
  -                                     isAttrName = false;
  -
                                        if(-1 != posOfNSSep)
                                        {          
                                                posOfNSSep = mapNSTokens(pat, 
startSubstring, posOfNSSep, i);
  @@ -284,9 +273,6 @@
                        {
                                if(startSubstring != -1)
                                {
  -                                     isStartOfPat = 
mapPatternElemPos(nesting, isStartOfPat, isAttrName);
  -                                     isAttrName = false;
  -
                                        if(-1 != posOfNSSep)
                                        {        
                                                posOfNSSep = mapNSTokens(pat, 
startSubstring, posOfNSSep, i);
  @@ -325,9 +311,6 @@
                        {
                                if(startSubstring != -1)
                                {
  -                                     isStartOfPat = 
mapPatternElemPos(nesting, isStartOfPat, isAttrName);
  -                                     isAttrName = false;
  -
                                        if(-1 != posOfNSSep)
                                        {        
                                                posOfNSSep = mapNSTokens(pat, 
startSubstring, posOfNSSep, i);
  @@ -344,22 +327,16 @@
                        }
                        break;
                
  -             case XalanUnicode::charCommercialAt:
  -                     isAttrName = true;
  -                     // fall-through on purpose
  -
                case XalanUnicode::charHyphenMinus:
                        {
  -                             if(XalanUnicode::charHyphenMinus == c)
  +                             if(!(startSubstring == -1))
                                {
  -                                     if(!(startSubstring == -1))
  -                                     {
  -                                             break;
  -                                     }
  +                                     break;
                                }
                        }
                        // fall-through on purpose
   
  +             case XalanUnicode::charCommercialAt:
                case XalanUnicode::charLeftParenthesis:
                case XalanUnicode::charLeftSquareBracket:
                case XalanUnicode::charRightParenthesis:
  @@ -379,9 +356,6 @@
                        {
                                if(startSubstring != -1)
                                {
  -                                     isStartOfPat = 
mapPatternElemPos(nesting, isStartOfPat, isAttrName);
  -                                     isAttrName = false;
  -
                                        if(-1 != posOfNSSep)
                                        {        
                                                posOfNSSep = mapNSTokens(pat, 
startSubstring, posOfNSSep, i);
  @@ -395,32 +369,6 @@
   
                                        startSubstring = -1;
                                }
  -                             else if(XalanUnicode::charSolidus == c && 
isStartOfPat == true)
  -                             {
  -                                     isStartOfPat = 
mapPatternElemPos(nesting, isStartOfPat, isAttrName);
  -                             }
  -                             else if(XalanUnicode::charAsterisk == c)
  -                             {
  -                                     isStartOfPat = 
mapPatternElemPos(nesting, isStartOfPat, isAttrName);
  -                                     isAttrName = false;
  -                             }
  -
  -                             if(0 == nesting)
  -                             {
  -                                     if(XalanUnicode::charVerticalLine == c)
  -                                     {
  -                                             isStartOfPat = true;
  -                                     }
  -                             }
  -
  -                             if(XalanUnicode::charRightParenthesis == c || 
XalanUnicode::charRightSquareBracket == c)
  -                             {
  -                                     nesting--;
  -                             }
  -                             else if(XalanUnicode::charLeftParenthesis == c 
|| XalanUnicode::charLeftSquareBracket == c)
  -                             {
  -                                     nesting++;
  -                             }
   
                                substring(pat, theToken, i, i + 1);
   
  @@ -442,7 +390,6 @@
                                                }
                                        }
   
  -                                     isAttrName = false;
                                        startSubstring = -1;
                                        posOfNSSep = -1;
   
  @@ -509,8 +456,6 @@
   
        if(startSubstring != -1)
        {
  -             isStartOfPat = mapPatternElemPos(nesting, isStartOfPat, 
isAttrName);
  -
                if(-1 != posOfNSSep)
                {        
                        posOfNSSep = mapNSTokens(pat, startSubstring, 
posOfNSSep, nChars);
  @@ -533,34 +478,6 @@
   
   
   
  -bool
  -XPathProcessorImpl::mapPatternElemPos(
  -                     int     nesting,
  -                     bool    isStart,
  -                     bool    isAttrName) const
  -{
  -     if(0 == nesting)
  -     {
  -             if(!isStart)
  -             {
  -                     m_expression->adjustPattern(
  -                             m_expression->patternMapSize() - 1,
  -                             -TARGETEXTRA);
  -             }
  -
  -             const int       theValue =
  -                     m_expression->tokenQueueSize() - (isAttrName ? 1 : 0) + 
TARGETEXTRA;
  -
  -             m_expression->pushPattern(theValue);
  -
  -             isStart = false;
  -     }
  -
  -     return isStart;
  -}
  -
  -
  -
   void
   XPathProcessorImpl::addToTokenQueue(const XalanDOMString&    s) const
   {
  @@ -582,12 +499,12 @@
        StringToStringMapType::const_iterator   i = m_namespaces.find(m_token);
        assert(i != m_namespaces.end());
   
  -     const XalanDOMString&   theNamespaceURI = (*i).second;
  -     assert(theNamespaceURI.size() != 0);
  +     const XalanDOMString* const             theNamespaceURI = (*i).second;
  +     assert(theNamespaceURI != 0 && theNamespaceURI->size() != 0);
   
        m_expression->replaceRelativeToken(
                        -1,
  -                     theNamespaceURI);
  +                     *theNamespaceURI);
   }
   
   
  @@ -632,7 +549,7 @@
        }
        else
        {
  -             m_namespaces[scratchString] = *uName;
  +             m_namespaces[scratchString] = uName;
   
                addToTokenQueue(scratchString);
   
  @@ -661,18 +578,6 @@
        }
   
        return -1;
  -}
  -
  -
  -
  -int
  -XPathProcessorImpl::getTokenQueuePosFromMap(int      i) const
  -{
  -     assert(m_expression != 0);
  -
  -     const int       pos = m_expression->getPattern(i);
  -
  -     return pos >= TARGETEXTRA ? pos - TARGETEXTRA : pos;
   }
   
   
  
  
  
  1.32      +4 -64     xml-xalan/c/src/XPath/XPathProcessorImpl.hpp
  
  Index: XPathProcessorImpl.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XPath/XPathProcessorImpl.hpp,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- XPathProcessorImpl.hpp    7 Jan 2003 00:40:55 -0000       1.31
  +++ XPathProcessorImpl.hpp    8 May 2003 18:13:21 -0000       1.32
  @@ -2,7 +2,7 @@
    * The Apache Software License, Version 1.1
    *
    *
  - * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights 
  + * Copyright (c) 1999-2003 The Apache Software Foundation.  All rights 
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -101,7 +101,7 @@
   
   #if defined(XALAN_NO_STD_NAMESPACE)
        typedef map<XalanDOMString,
  -                             XalanDOMString,
  +                             const XalanDOMString*,
                                less<XalanDOMString> >  StringToStringMapType;
   
   #if defined(XALAN_USE_DEQUE_FOR_VECTOR_BOOL)
  @@ -111,7 +111,7 @@
   #endif
   #else
        typedef std::map<XalanDOMString,
  -                                      XalanDOMString>        
StringToStringMapType;
  +                                      const XalanDOMString*>         
StringToStringMapType;
   
   #if defined(XALAN_USE_DEQUE_FOR_VECTOR_BOOL)
        typedef std::deque<bool>                        BoolVectorType;
  @@ -155,17 +155,6 @@
        void
        tokenize(const XalanDOMString&  pat);
     
  -     /**
  -      * Record the current position on the token queue as long as this is a
  -      * top-level element.  Must be called before the next token is added to 
the
  -      * m_tokenQueue.
  -      */
  -     bool
  -     mapPatternElemPos(
  -                     int             nesting,
  -                     bool    isStart,
  -                     bool    isAttrName) const;
  -
        void
        addToTokenQueue(const XalanDOMString&   s) const;
   
  @@ -184,52 +173,6 @@
                        int                                             
posOfScan);
   
        /**
  -      * Given a map pos, return the corresponding token queue pos.
  -      */
  -     int
  -     getTokenQueuePosFromMap(int             i) const;
  -
  -     /**
  -      * This will return the index above the passed index that is the target
  -      * element, i.e. it holds a value >= TARGETEXTRA. If there is no next
  -      * target, it will return -1. Pass -1 in to start testing from zero.
  -      */
  -     int
  -     getNextTargetIndexInMap(int             i) const;
  -  
  -     /**
  -      * This will return the normalized index into the pattern 
  -      * map above the passed index, or -1 if it is the last pattern.
  -      */
  -     int
  -     getNextIndexInMap(int   i) const;
  -  
  -     /**
  -      * This will return the index above the passed index that 
  -      * is the start if the next subpattern, or -1 if there is none.
  -      * If there is no next target, it will return -1.
  -      * Pass -1 in to start testing from zero.
  -      */
  -     int
  -     getNextSubpatternStartIndexInMap(int    i) const;
  -
  -     /**
  -      * This will return the next index from the passed index,
  -      * or -1 if it the passed index is the last index of the 
  -      * subpattern.
  -      */
  -     int
  -     getNextPatternPos(int   i) const;
  -
  -     /**
  -      * This will return the previous index from the passed index,
  -      * or -1 if it the passed index is the first index of the 
  -      * subpattern.
  -      */
  -     int
  -     getPrevMapIndex(int             i) const;
  -
  -     /**
         * Check if m_token==s. If m_token is null, this won't throw
         * an exception, instead it just returns false (or true
         * if s is also null).
  @@ -856,11 +799,8 @@
   
        StringToStringMapType                   m_namespaces;
   
  -     enum eDummy
  -     {
  -             TARGETEXTRA = 10000
  -     };
   
  +     // Static stuff here...
        static const XalanDOMString             s_emptyString;
   
        static const XalanDOMChar               s_functionIDString[];
  
  
  

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

Reply via email to