xml-xmlbeans-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eric...@apache.org
Subject cvs commit: xml-xmlbeans/v2/src/newstore2/org/apache/xmlbeans/impl/newstore2 Cur.java Jsr173.java Locale.java
Date Thu, 19 Aug 2004 00:32:24 GMT
ericvas     2004/08/18 17:32:24

  Modified:    v2/src/newstore2/org/apache/xmlbeans/impl/newstore2 Cur.java
                        Jsr173.java Locale.java
  Log:
  Fixed temp handling of low-level Curs
  
  Revision  Changes    Path
  1.44      +47 -27    xml-xmlbeans/v2/src/newstore2/org/apache/xmlbeans/impl/newstore2/Cur.java
  
  Index: Cur.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/newstore2/org/apache/xmlbeans/impl/newstore2/Cur.java,v
  retrieving revision 1.43
  retrieving revision 1.44
  diff -u -r1.43 -r1.44
  --- Cur.java	18 Aug 2004 15:25:51 -0000	1.43
  +++ Cur.java	19 Aug 2004 00:32:24 -0000	1.44
  @@ -2544,43 +2544,62 @@
   
       void release ( )
       {
  -        if (_state == POOLED || _state == DISPOSED)
  -            return;
  +        if (_tempFrame >= 0)
  +        {
  +            if (_nextTemp != null)
  +                _nextTemp._prevTemp = _prevTemp;
  +                
  +            if (_prevTemp == null)
  +                _locale._tempFrames[ _tempFrame ] = _nextTemp;
  +            else
  +                _prevTemp._nextTemp = _nextTemp;
   
  -        moveToCur( null );
  +            _prevTemp = _nextTemp = null;
  +            _tempFrame = -1;
  +        }
   
  -        assert isNormal();
  +        if (_state != POOLED && _state != DISPOSED)
  +        {
  +            moveToCur( null );
   
  -        assert _xobj == null;
  -        assert _pos  == NO_POS;
  +            assert isNormal();
   
  -        if (_value instanceof Locale.Ref)
  -            ((Locale.Ref) _value).clear();
  +            assert _xobj == null;
  +            assert _pos  == NO_POS;
   
  -        _value = null;
  -        _key = null;
  +            if (_value != null && _value instanceof Locale.Ref)
  +            {
  +                Locale.Ref r = (Locale.Ref) _value;
   
  -        assert _state == REGISTERED;
  -        _locale._registered = listRemove( _locale._registered );
  +                r.clear();
  +                r._cur = null;
  +            }
   
  -        if (_locale._curPoolCount < 16)
  -        {
  -            _locale._curPool = listInsert( _locale._curPool );
  -            _state = POOLED;
  -            _locale._curPoolCount++;
  -        }
  -        else
  -        {
  -            _locale = null;
  -            _state = DISPOSED;
  -        }
  +            _value = null;
  +            _key = null;
   
  -        while ( _stackTop != -1 )
  -            popButStay();
  +            assert _state == REGISTERED;
  +            _locale._registered = listRemove( _locale._registered );
   
  -        clearSelection();
  +            if (_locale._curPoolCount < 16)
  +            {
  +                _locale._curPool = listInsert( _locale._curPool );
  +                _state = POOLED;
  +                _locale._curPoolCount++;
  +            }
  +            else
  +            {
  +                _locale = null;
  +                _state = DISPOSED;
  +            }
  +
  +            while ( _stackTop != -1 )
  +                popButStay();
   
  -        _id = null;
  +            clearSelection();
  +
  +            _id = null;
  +        }
       }
   
       boolean isOnList ( Cur head )
  @@ -3326,6 +3345,7 @@
       String _id;
   
       Cur _nextTemp;
  +    Cur _prevTemp;
       int _tempFrame;
   
       Cur _next;
  
  
  
  1.15      +15 -11    xml-xmlbeans/v2/src/newstore2/org/apache/xmlbeans/impl/newstore2/Jsr173.java
  
  Index: Jsr173.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/newstore2/org/apache/xmlbeans/impl/newstore2/Jsr173.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- Jsr173.java	16 Aug 2004 15:58:25 -0000	1.14
  +++ Jsr173.java	19 Aug 2004 00:32:24 -0000	1.15
  @@ -51,9 +51,13 @@
       
       public static Node nodeFromStreamImpl ( Jsr173GateWay gw )
       {
  -        Cur c = gw._xs.getCur();
  +        Cur c = gw._xs.getStreamCur();
   
  -        return c.isNode() ? (Node) c.getDom() : (Node) null;
  +        Node n = c.isNode() ? (Node) c.getDom() : (Node) null;
  +
  +        c.release();
  +
  +        return n;
       }
   
       public static XMLStreamReader newXmlStreamReader ( Cur c, Object src, int off, int
cch )
  @@ -172,7 +176,7 @@
               assert _wholeDoc || !_cur.isSamePos( _end );
           }
   
  -        protected Cur getCur ( )
  +        protected Cur getStreamCur ( )
           {
               return _cur;
           }
  @@ -813,7 +817,7 @@
           {
               checkChanged();
   
  -            Cur c = getCur();
  +            Cur c = getStreamCur();
   
               XmlLineNumber ln = (XmlLineNumber) c.getBookmark( XmlLineNumber.class );
   
  @@ -853,7 +857,7 @@
           {
               checkChanged();
   
  -            XmlDocumentProperties props = _locale.getDocProps( getCur(), false );
  +            XmlDocumentProperties props = _locale.getDocProps( getStreamCur(), false );
   
               return props == null ? null : props.getEncoding();
           }
  @@ -868,7 +872,7 @@
           {
               checkChanged();
   
  -            XmlDocumentProperties props = _locale.getDocProps( getCur(), false );
  +            XmlDocumentProperties props = _locale.getDocProps( getStreamCur(), false );
   
               return props == null ? null : props.getVersion();
           }
  @@ -877,7 +881,7 @@
           {
               checkChanged();
   
  -            XmlDocumentProperties props = _locale.getDocProps( getCur(), false );
  +            XmlDocumentProperties props = _locale.getDocProps( getStreamCur(), false );
   
               return props == null ? false : props.getStandalone();
           }
  @@ -925,7 +929,7 @@
           {
               checkChanged();
   
  -            Cur c = getCur();
  +            Cur c = getStreamCur();
   
               c.push();
   
  @@ -943,7 +947,7 @@
           {
               checkChanged();
   
  -            Cur c = getCur();
  +            Cur c = getStreamCur();
   
               c.push();
   
  @@ -974,7 +978,7 @@
           //
           //
   
  -        protected abstract Cur getCur ( );
  +        protected abstract Cur getStreamCur ( );
   
           //
           //
  @@ -1007,7 +1011,7 @@
               _cur = c;
           }
   
  -        protected Cur getCur ( )
  +        protected Cur getStreamCur ( )
           {
               return _cur;
           }
  
  
  
  1.24      +37 -38    xml-xmlbeans/v2/src/newstore2/org/apache/xmlbeans/impl/newstore2/Locale.java
  
  Index: Locale.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/newstore2/org/apache/xmlbeans/impl/newstore2/Locale.java,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- Locale.java	16 Aug 2004 15:58:25 -0000	1.23
  +++ Locale.java	19 Aug 2004 00:32:24 -0000	1.24
  @@ -1971,7 +1971,8 @@
           assert o != null && !(o instanceof Ref);
           
           Cur c = getCur();
  -        
  +
  +        assert c._tempFrame == -1;
           assert c._value == null;
   
           c._value = new Ref( c, o );
  @@ -1996,7 +1997,7 @@
               _cur = c;
           }
   
  -        final Cur _cur;
  +        Cur _cur;
       }
   
       Cur tempCur ( )
  @@ -2008,20 +2009,28 @@
       {
           Cur c = getCur();
   
  -        if (c._tempFrame < 0)
  -        {
  -            assert _numTempFramesLeft < _tempFrames.length : "Temp frame not pushed";
  -                
  -            int frame = _tempFrames.length - _numTempFramesLeft - 1;
  +        assert c._tempFrame == -1;
   
  -            assert frame >= 0 && frame < _tempFrames.length;
  +        assert _numTempFramesLeft < _tempFrames.length : "Temp frame not pushed";
   
  -            c._nextTemp = _tempFrames[ frame ];
  -            _tempFrames[ frame ] = c;
  -        
  -            c._tempFrame = frame;
  +        int frame = _tempFrames.length - _numTempFramesLeft - 1;
  +
  +        assert frame >= 0 && frame < _tempFrames.length;
  +
  +        Cur next = _tempFrames[ frame ];
  +
  +        c._nextTemp = next;
  +        assert c._prevTemp == null;
  +
  +        if (next != null)
  +        {
  +            assert next._prevTemp == null;
  +            next._prevTemp = c;
           }
   
  +        _tempFrames[ frame ] = c;
  +        c._tempFrame = frame;
  +
           c._id = id;
           
           return c;
  @@ -2100,19 +2109,24 @@
           
           if (++_entryCount > 1000)
           {
  +            pollQueue();
               _entryCount = 0;
  +        }
  +    }
   
  -            if (_refQueue != null)
  +    private void pollQueue ( )
  +    {
  +        if (_refQueue != null)
  +        {
  +            for ( ; ; )
               {
  -                for ( ; ; )
  -                {
  -                    Ref ref = (Ref) _refQueue.poll();
  +                Ref ref = (Ref) _refQueue.poll();
   
  -                    if (ref == null)
  -                        break;
  +                if (ref == null)
  +                    break;
   
  +                if (ref._cur != null)
                       ref._cur.release();
  -                }
               }
           }
       }
  @@ -2131,23 +2145,8 @@
   
           int frame = _tempFrames.length - ++_numTempFramesLeft;
   
  -        Cur c = _tempFrames [ frame ];
  -
  -        _tempFrames [ frame ] = null;
  -        
  -        while ( c != null )
  -        {
  -            assert c._tempFrame == frame;
  -
  -            Cur next = c._nextTemp;
  -
  -            c._nextTemp = null;
  -            c._tempFrame = -1;
  -
  -            c.release();
  -
  -            c = next;
  -        }
  +        while ( _tempFrames[ frame ] != null )
  +            _tempFrames[ frame ].release();
       }
       
       //
  @@ -2810,8 +2809,8 @@
       private ReferenceQueue _refQueue;
       private int            _entryCount;
      
  -    private int   _numTempFramesLeft;
  -    private Cur[] _tempFrames;
  +    int   _numTempFramesLeft;
  +    Cur[] _tempFrames;
   
       Cur _curPool;
       int _curPoolCount;
  
  
  

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


Mime
View raw message