public void append(char c) { // Using shared buffer so far? if (mInputStart >= 0) { unshare(16); } mResultString = null; mResultArray = null; // Room in current segment? char[] curr = mCurrentSegment; if (mCurrentSize >= curr.length) { expand(1); curr = mCurrentSegment; } curr[mCurrentSize++] = c; }
public void append(String str) { // Can't append to shared buf (sanity check) int len = str.length(); if (mInputStart >= 0) { unshare(len); } mResultString = null; mResultArray = null; // Room in current segment? char[] curr = mCurrentSegment; int max = curr.length - mCurrentSize; if (max >= len) { str.getChars(0, len, curr, mCurrentSize); mCurrentSize += len; } else { // No room for all, need to copy part(s): if (max > 0) { str.getChars(0, max, curr, mCurrentSize); len -= max; } /* And then allocate new segment; we are guaranteed to now * have enough room in segment. */ expand(len); str.getChars(max, max+len, mCurrentSegment, 0); mCurrentSize = len; } }
public void append(char[] c, int start, int len) { // Can't append to shared buf (sanity check) if (mInputStart >= 0) { unshare(len); } mResultString = null; mResultArray = null; // Room in current segment? char[] curr = mCurrentSegment; int max = curr.length - mCurrentSize; if (max >= len) { System.arraycopy(c, start, curr, mCurrentSize, len); mCurrentSize += len; } else { // No room for all, need to copy part(s): if (max > 0) { System.arraycopy(c, start, curr, mCurrentSize, max); start += max; len -= max; } /* And then allocate new segment; we are guaranteed to now * have enough room in segment. */ expand(len); // note: curr != mCurrentSegment after this System.arraycopy(c, start, mCurrentSegment, 0, len); mCurrentSize = 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; }
public void append(char c) { // Using shared buffer so far? if (mInputStart >= 0) { unshare(16); } mResultString = null; mResultArray = null; // Room in current segment? char[] curr = mCurrentSegment; if (mCurrentSize >= curr.length) { expand(1); } curr[mCurrentSize++] = c; }
public void append(char c) { // Using shared buffer so far? if (mInputStart >= 0) { unshare(16); } mResultString = null; mResultArray = null; // Room in current segment? char[] curr = mCurrentSegment; if (mCurrentSize >= curr.length) { expand(1); } curr[mCurrentSize++] = c; }
public void append(char c) { // Using shared buffer so far? if (mInputStart >= 0) { unshare(16); } mResultString = null; mResultArray = null; // Room in current segment? char[] curr = mCurrentSegment; if (mCurrentSize >= curr.length) { expand(1); curr = mCurrentSegment; } curr[mCurrentSize++] = c; }
public void append(char c) { // Using shared buffer so far? if (mInputStart >= 0) { unshare(16); } mResultString = null; mResultArray = null; // Room in current segment? char[] curr = mCurrentSegment; if (mCurrentSize >= curr.length) { expand(1); } curr[mCurrentSize++] = c; }
public void append(char c) { // Using shared buffer so far? if (mInputStart >= 0) { unshare(16); } mResultString = null; mResultArray = null; // Room in current segment? char[] curr = mCurrentSegment; if (mCurrentSize >= curr.length) { expand(1); curr = mCurrentSegment; } curr[mCurrentSize++] = c; }
public void append(char c) { // Using shared buffer so far? if (mInputStart >= 0) { unshare(16); } mResultString = null; mResultArray = null; // Room in current segment? char[] curr = mCurrentSegment; if (mCurrentSize >= curr.length) { expand(1); curr = mCurrentSegment; } curr[mCurrentSize++] = c; }
public void append(char c) { // Using shared buffer so far? if (mInputStart >= 0) { unshare(16); } mResultString = null; mResultArray = null; // Room in current segment? char[] curr = mCurrentSegment; if (mCurrentSize >= curr.length) { expand(1); curr = mCurrentSegment; } curr[mCurrentSize++] = c; }
public void append(char[] c, int start, int len) { // Can't append to shared buf (sanity check) if (mInputStart >= 0) { unshare(len); } mResultString = null; mResultArray = null; // Room in current segment? char[] curr = mCurrentSegment; int max = curr.length - mCurrentSize; if (max >= len) { System.arraycopy(c, start, curr, mCurrentSize, len); mCurrentSize += len; } else { // No room for all, need to copy part(s): if (max > 0) { System.arraycopy(c, start, curr, mCurrentSize, max); start += max; len -= max; } /* And then allocate new segment; we are guaranteed to now * have enough room in segment. */ expand(len); // note: curr != mCurrentSegment after this System.arraycopy(c, start, mCurrentSegment, 0, len); mCurrentSize = len; } }
public void append(String str) { // Can't append to shared buf (sanity check) int len = str.length(); if (mInputStart >= 0) { unshare(len); } mResultString = null; mResultArray = null; // Room in current segment? char[] curr = mCurrentSegment; int max = curr.length - mCurrentSize; if (max >= len) { str.getChars(0, len, curr, mCurrentSize); mCurrentSize += len; } else { // No room for all, need to copy part(s): if (max > 0) { str.getChars(0, max, curr, mCurrentSize); len -= max; } /* And then allocate new segment; we are guaranteed to now * have enough room in segment. */ expand(len); str.getChars(max, len, mCurrentSegment, 0); mCurrentSize = 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(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 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 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; }