/** * Method called if/when we need to append content when we have been * initialized to use shared buffer. */ public void unshare(int needExtra) { int len = mInputLen; mInputLen = 0; char[] inputBuf = mInputBuffer; mInputBuffer = null; int start = mInputStart; mInputStart = -1; // Is buffer big enough, or do we need to reallocate? int needed = len+needExtra; if (mCurrentSegment == null || needed > mCurrentSegment.length) { mCurrentSegment = allocBuffer(needed); } if (len > 0) { System.arraycopy(inputBuf, start, mCurrentSegment, 0, len); } mSegmentSize = 0; mCurrentSize = len; }
/** * Method called to make sure there is a non-shared segment to use, without * appending any content yet. */ public void resetInitialized() { resetWithEmpty(); if (mCurrentSegment == null) { mCurrentSegment = allocBuffer(0); } }
public void resetWithCopy(char[] buf, int start, int len) { mInputBuffer = null; mInputStart = -1; // indicates shared buffer not used mInputLen = 0; mResultString = null; mResultArray = null; // And then reset internal input buffers, if necessary: if (mHasSegments) { clearSegments(); } else { if (mCurrentSegment == null) { mCurrentSegment = allocBuffer(len); } mCurrentSize = mSegmentSize = 0; } append(buf, start, len); }
public char[] getCurrentSegment() { /* Since the intention of the caller is to directly add stuff into * buffers, we should NOT have anything in shared buffer... ie. may * need to unshare contents. */ if (mInputStart >= 0) { unshare(1); } else { char[] curr = mCurrentSegment; if (curr == null) { mCurrentSegment = allocBuffer(0); } else if (mCurrentSize >= curr.length) { // Plus, we better have room for at least one more char expand(1); } } return mCurrentSegment; }
/** * Method called to make sure there is a non-shared segment to use, without * appending any content yet. */ public void resetInitialized() { resetWithEmpty(); if (mCurrentSegment == null) { mCurrentSegment = allocBuffer(0); } }
/** * Method called to make sure there is a non-shared segment to use, without * appending any content yet. */ public void resetInitialized() { resetWithEmpty(); if (mCurrentSegment == null) { mCurrentSegment = allocBuffer(0); } }
/** * Method called to make sure there is a non-shared segment to use, without * appending any content yet. */ public void resetInitialized() { resetWithEmpty(); if (mCurrentSegment == null) { mCurrentSegment = allocBuffer(0); } }
/** * Method called to make sure there is a non-shared segment to use, without * appending any content yet. */ public void resetInitialized() { resetWithEmpty(); if (mCurrentSegment == null) { mCurrentSegment = allocBuffer(0); } }
/** * Method called to make sure there is a non-shared segment to use, without * appending any content yet. */ public void resetInitialized() { resetWithEmpty(); if (mCurrentSegment == null) { mCurrentSegment = allocBuffer(mInitialBufSize); } }
/** * Method called to make sure there is a non-shared segment to use, without * appending any content yet. */ public void resetInitialized() { resetWithEmpty(); if (mCurrentSegment == null) { mCurrentSegment = allocBuffer(mInitialBufSize); } }
/** * Method called to make sure there is a non-shared segment to use, without * appending any content yet. */ public void resetInitialized() { resetWithEmpty(); if (mCurrentSegment == null) { mCurrentSegment = allocBuffer(mInitialBufSize); } }
public void resetWithCopy(char[] buf, int start, int len) { mInputBuffer = null; mInputStart = -1; // indicates shared buffer not used mInputLen = 0; mResultString = null; mResultArray = null; // And then reset internal input buffers, if necessary: if (mHasSegments) { clearSegments(); } else { if (mCurrentSegment == null) { mCurrentSegment = allocBuffer(len); } mCurrentSize = mSegmentSize = 0; } append(buf, start, len); }
public void resetWithCopy(char[] buf, int start, int len) { mInputBuffer = null; mInputStart = -1; // indicates shared buffer not used mInputLen = 0; mResultString = null; mResultArray = null; // And then reset internal input buffers, if necessary: if (mHasSegments) { clearSegments(); } else { if (mCurrentSegment == null) { mCurrentSegment = allocBuffer(len); } mCurrentSize = mSegmentSize = 0; } append(buf, start, len); }
public char[] getCurrentSegment() { /* Since the intention of the caller is to directly add stuff into * buffers, we should NOT have anything in shared buffer... ie. may * need to unshare contents. */ if (mInputStart >= 0) { unshare(1); } else { char[] curr = mCurrentSegment; if (curr == null) { mCurrentSegment = allocBuffer(mInitialBufSize); } else if (mCurrentSize >= curr.length) { // Plus, we better have room for at least one more char expand(1); } } return mCurrentSegment; }
public void resetWithCopy(char[] buf, int start, int len) { mInputBuffer = null; mInputStart = -1; // indicates shared buffer not used mInputLen = 0; mResultString = null; mResultArray = null; // And then reset internal input buffers, if necessary: if (mHasSegments) { clearSegments(); } else { if (mCurrentSegment == null) { mCurrentSegment = allocBuffer(len); } mCurrentSize = mSegmentSize = 0; } append(buf, start, len); }
public char[] getCurrentSegment() { /* Since the intention of the caller is to directly add stuff into * buffers, we should NOT have anything in shared buffer... ie. may * need to unshare contents. */ if (mInputStart >= 0) { unshare(1); } else { char[] curr = mCurrentSegment; if (curr == null) { mCurrentSegment = allocBuffer(mInitialBufSize); } else if (mCurrentSize >= curr.length) { // Plus, we better have room for at least one more char expand(1); } } return mCurrentSegment; }
public char[] getCurrentSegment() { /* Since the intention of the caller is to directly add stuff into * buffers, we should NOT have anything in shared buffer... ie. may * need to unshare contents. */ if (mInputStart >= 0) { unshare(1); } else { char[] curr = mCurrentSegment; if (curr == null) { mCurrentSegment = allocBuffer(0); } else if (mCurrentSize >= curr.length) { // Plus, we better have room for at least one more char expand(1); } } return mCurrentSegment; }
public char[] getCurrentSegment() { /* Since the intention of the caller is to directly add stuff into * buffers, we should NOT have anything in shared buffer... ie. may * need to unshare contents. */ if (mInputStart >= 0) { unshare(1); } else { char[] curr = mCurrentSegment; if (curr == null) { mCurrentSegment = allocBuffer(mInitialBufSize); } else if (mCurrentSize >= curr.length) { // Plus, we better have room for at least one more char expand(1); } } return mCurrentSegment; }
public void resetWithCopy(char[] buf, int start, int len) { mInputBuffer = null; mInputStart = -1; // indicates shared buffer not used mInputLen = 0; mResultString = null; mResultArray = null; // And then reset internal input buffers, if necessary: if (mHasSegments) { clearSegments(); } else { if (mCurrentSegment == null) { mCurrentSegment = allocBuffer(len); } mCurrentSize = mSegmentSize = 0; } append(buf, start, len); }
public char[] getCurrentSegment() { /* Since the intention of the caller is to directly add stuff into * buffers, we should NOT have anything in shared buffer... ie. may * need to unshare contents. */ if (mInputStart >= 0) { unshare(1); } else { char[] curr = mCurrentSegment; if (curr == null) { mCurrentSegment = allocBuffer(0); } else if (mCurrentSize >= curr.length) { // Plus, we better have room for at least one more char expand(1); } } return mCurrentSegment; }