@@ -332,11 +332,6 @@ public int getFirstTag() {
332332     */ 
333333    protected  int  _typeByte ;
334334
335-     /** 
336-      * A pointer to know where to write text when we share an output buffer across methods 
337-      */ 
338-     protected  int  _sharedOutBufferPtr ;
339- 
340335    /** 
341336     * Type to keep track of a list of string references. A depth is stored to know when to pop the 
342337     * references off the stack for nested namespaces. 
@@ -2460,7 +2455,7 @@ private final String _finishLongText(int len) throws IOException
24602455        // First a tight loop for ASCII. 
24612456        len  = _finishLongTextAscii (len );
24622457        char [] outBuf  = _textBuffer .getBufferWithoutReset ();
2463-         int  outPtr  = _sharedOutBufferPtr ;
2458+         int  outPtr  = _textBuffer . getCurrentSegmentSize () ;
24642459        int  outEnd  = outBuf .length ;
24652460        final  int [] codes  = UTF8_UNIT_CODES ;
24662461
@@ -2530,12 +2525,10 @@ private final int _finishLongTextAscii(int len) throws IOException
25302525    {
25312526        char [] outBuf  = _textBuffer .emptyAndGetCurrentSegment ();
25322527        final  byte [] input  = _inputBuffer ;
2533-         _sharedOutBufferPtr  = 0 ;
25342528        while  (len  > 0 ) {
25352529            // load as much input as possible 
25362530            int  size  = Math .min (len , Math .min (outBuf .length , input .length ));
25372531            if  (!_tryToLoadToHaveAtLeast (size )) {
2538-                 _sharedOutBufferPtr  = 0 ;
25392532                return  len ;
25402533            }
25412534            int  outEnd  = size ;
@@ -2549,9 +2542,10 @@ private final int _finishLongTextAscii(int len) throws IOException
25492542            }
25502543            // Found a non-ascii char, correct pointers and return to the caller. 
25512544            if  (i  < 0 ) {
2545+                 --outPtr ;
25522546                _inputPtr  = inPtr  - 1 ;
2553-                 _sharedOutBufferPtr  =  outPtr  -  1 ;
2554-                 return  len  - _sharedOutBufferPtr ;
2547+                 _textBuffer . setCurrentLength ( outPtr ) ;
2548+                 return  len  - outPtr ;
25552549            }
25562550            _inputPtr  = inPtr ;
25572551            if  (outPtr  >= outBuf .length ) {
@@ -2596,17 +2590,17 @@ private final void _finishChunkedText() throws IOException
25962590                    }
25972591                    // start of a new chunk 
25982592                    // First a tight loop for ASCII. 
2599-                     _sharedOutBufferPtr  =  outPtr ;
2593+                     _textBuffer . setCurrentLength ( outPtr ) ;
26002594                    if  (_finishChunkedTextAscii ()) {
26012595                        // chunk fully consumed, let's get the next one 
26022596                        outBuf  = _textBuffer .getBufferWithoutReset ();
2603-                         outPtr  = _sharedOutBufferPtr ;
2597+                         outPtr  = _textBuffer . getCurrentSegmentSize () ;
26042598                        outEnd  = outBuf .length ;
26052599                        continue ;
26062600                    }
26072601                    outBuf  = _textBuffer .getBufferWithoutReset ();
2602+                     outPtr  = _textBuffer .getCurrentSegmentSize ();
26082603                    outEnd  = outBuf .length ;
2609-                     outPtr  = _sharedOutBufferPtr ;
26102604                }
26112605                // besides of which just need to ensure there's content 
26122606                _loadMoreForChunkIfNeeded ();
@@ -2670,7 +2664,7 @@ private final void _finishChunkedText() throws IOException
26702664    private  final  boolean  _finishChunkedTextAscii () throws  IOException 
26712665    {
26722666        final  byte [] input  = _inputBuffer ;
2673-         int  outPtr  = _sharedOutBufferPtr ;
2667+         int  outPtr  = _textBuffer . getCurrentSegmentSize () ;
26742668        char [] outBuf  = _textBuffer .getBufferWithoutReset ();
26752669        int  outEnd  = outBuf .length ;
26762670        while  (true ) {
@@ -2693,9 +2687,8 @@ private final boolean _finishChunkedTextAscii() throws IOException
26932687
26942688            if  (i  < 0 ) {
26952689                // Found a non-ascii char, correct pointers and return to the caller. 
2696-                 outPtr  -= 1 ;
26972690                _inputPtr  -= 1 ;
2698-                 _sharedOutBufferPtr  =  outPtr ;
2691+                 _textBuffer . setCurrentLength ( outPtr  -  1 ) ;
26992692                // return false to signal this to the calling code to allow the multi-byte code-path to kick. 
27002693                return  false ;
27012694            }
@@ -2708,7 +2701,7 @@ private final boolean _finishChunkedTextAscii() throws IOException
27082701            if  (_inputPtr  < _chunkEnd  || _chunkLeft  > 0 ) {
27092702                continue ;
27102703            }
2711-             _sharedOutBufferPtr  =  outPtr ;
2704+             _textBuffer . setCurrentLength ( outPtr ) ;
27122705            return  true ;
27132706        }
27142707    }
0 commit comments