public static void set(int idx, byte[] source, int startFrom, int copyLength, int sourceMask, LocalHeap heap) { int offset = idx << 2; heap.totalContent += (copyLength - (heap.tat[offset + 1] - heap.tat[offset])); int target = heap.makeRoom(offset, copyLength); heap.tat[offset] = target; heap.tat[offset + 1] = target + copyLength; int i = copyLength; while (--i>=0) { heap.data[target+i] = source[sourceMask&(startFrom+i)]; } }
private void makeSpaceForPrepend(int offset, int textLength) { if (tat[offset] > tat[offset + 1]) { // null or empty string detected so change to simple set tat[offset + 1] = tat[offset]; } int start = tat[offset] - textLength; if (start < 0) { // must move this right first. makeRoomBeforeFirst(offset, textLength); start = tat[offset] - textLength; } if (start < 0) { start = 0; } int limit = offset - 3 < 0 ? 0 : tat[offset - 3]; if (start < limit) { int stop = tat[offset + 4]; int space = stop - limit; int need = tat[offset + 1] - start; if (need > space) { makeRoom(offset, true, need); } // we have some space so just shift the existing data. int len = tat[offset + 1] - tat[offset]; System.arraycopy(data, tat[offset], data, start, len); tat[offset] = start; tat[offset + 1] = start + len; } }
public static void set(int idx, byte[] source, int startFrom, int copyLength, int sourceMask, LocalHeap heap) { int offset = idx << 2; heap.totalContent += (copyLength - (heap.tat[offset + 1] - heap.tat[offset])); int target = heap.makeRoom(offset, copyLength); heap.tat[offset] = target; heap.tat[offset + 1] = target + copyLength; int i = copyLength; while (--i>=0) { heap.data[target+i] = source[sourceMask&(startFrom+i)]; } }
private void makeSpaceForPrepend(int offset, int textLength) { if (tat[offset] > tat[offset + 1]) { // null or empty string detected so change to simple set tat[offset + 1] = tat[offset]; } int start = tat[offset] - textLength; if (start < 0) { // must move this right first. makeRoomBeforeFirst(offset, textLength); start = tat[offset] - textLength; } if (start < 0) { start = 0; } int limit = offset - 3 < 0 ? 0 : tat[offset - 3]; if (start < limit) { int stop = tat[offset + 4]; int space = stop - limit; int need = tat[offset + 1] - start; if (need > space) { makeRoom(offset, true, need); } // we have some space so just shift the existing data. int len = tat[offset + 1] - tat[offset]; System.arraycopy(data, tat[offset], data, start, len); tat[offset] = start; tat[offset + 1] = start + len; } }
public static void set(int idx, byte[] source, int startFrom, int copyLength, int sourceMask, LocalHeap heap) { int offset = idx << 2; heap.totalContent += (copyLength - (heap.tat[offset + 1] - heap.tat[offset])); int target = heap.makeRoom(offset, copyLength); heap.tat[offset] = target; heap.tat[offset + 1] = target + copyLength; int i = copyLength; while (--i>=0) { heap.data[target+i] = source[sourceMask&(startFrom+i)]; } }
private void makeSpaceForPrepend(int offset, int textLength) { if (tat[offset] > tat[offset + 1]) { // null or empty string detected so change to simple set tat[offset + 1] = tat[offset]; } int start = tat[offset] - textLength; if (start < 0) { // must move this right first. makeRoomBeforeFirst(offset, textLength); start = tat[offset] - textLength; } if (start < 0) { start = 0; } int limit = offset - 3 < 0 ? 0 : tat[offset - 3]; if (start < limit) { int stop = tat[offset + 4]; int space = stop - limit; int need = tat[offset + 1] - start; if (need > space) { makeRoom(offset, true, need); } // we have some space so just shift the existing data. int len = tat[offset + 1] - tat[offset]; System.arraycopy(data, tat[offset], data, start, len); tat[offset] = start; tat[offset + 1] = start + len; } }
public static int allocate(int idx, int sourceLen, LocalHeap heap) { int offset = idx << 2; int target = heap.makeRoom(offset, sourceLen); int limit = target + sourceLen; if (limit > heap.dataLength) { target = heap.dataLength - sourceLen; } // full replace heap.totalContent += (sourceLen - (heap.tat[offset + 1] - heap.tat[offset])); heap.tat[offset] = target; heap.tat[offset + 1] = limit; return target; }
public static int allocate(int idx, int sourceLen, LocalHeap heap) { int offset = idx << 2; int target = heap.makeRoom(offset, sourceLen); int limit = target + sourceLen; if (limit > heap.dataLength) { target = heap.dataLength - sourceLen; } // full replace heap.totalContent += (sourceLen - (heap.tat[offset + 1] - heap.tat[offset])); heap.tat[offset] = target; heap.tat[offset + 1] = limit; return target; }
public static int allocate(int idx, int sourceLen, LocalHeap heap) { int offset = idx << 2; int target = heap.makeRoom(offset, sourceLen); int limit = target + sourceLen; if (limit > heap.dataLength) { target = heap.dataLength - sourceLen; } // full replace heap.totalContent += (sourceLen - (heap.tat[offset + 1] - heap.tat[offset])); heap.tat[offset] = target; heap.tat[offset + 1] = limit; return target; }
private int makeRoom(int offset, int sourceLen) { int prevTextStop = offset == 0 ? 0 : tat[offset - 3]; int nextTextStart = tat[offset + 4]; int space = nextTextStart - prevTextStop; int middleIdx = (space - sourceLen) >> 1; if (sourceLen > space) { // we do not have enough space move to the bigger side. makeRoom(offset, middleIdx > (dataLength >> 1), (sourceLen + tat[offset + 2] + tat[offset + 3]) - space); prevTextStop = offset == 0 ? 0 : tat[offset - 3]; nextTextStart = offset + 4 >= dataLength ? dataLength : tat[offset + 4]; middleIdx = ((nextTextStart - prevTextStop) - sourceLen) >> 1; } int target = prevTextStop + middleIdx; return target < 0 ? 0 : target; }
private int makeRoom(int offset, int sourceLen) { int prevTextStop = offset == 0 ? 0 : tat[offset - 3]; int nextTextStart = tat[offset + 4]; int space = nextTextStart - prevTextStop; int middleIdx = (space - sourceLen) >> 1; if (sourceLen > space) { // we do not have enough space move to the bigger side. makeRoom(offset, middleIdx > (dataLength >> 1), (sourceLen + tat[offset + 2] + tat[offset + 3]) - space); prevTextStop = offset == 0 ? 0 : tat[offset - 3]; nextTextStart = offset + 4 >= dataLength ? dataLength : tat[offset + 4]; middleIdx = ((nextTextStart - prevTextStop) - sourceLen) >> 1; } int target = prevTextStop + middleIdx; return target < 0 ? 0 : target; }
private int makeRoom(int offset, int sourceLen) { int prevTextStop = offset == 0 ? 0 : tat[offset - 3]; int nextTextStart = tat[offset + 4]; int space = nextTextStart - prevTextStop; int middleIdx = (space - sourceLen) >> 1; if (sourceLen > space) { // we do not have enough space move to the bigger side. makeRoom(offset, middleIdx > (dataLength >> 1), (sourceLen + tat[offset + 2] + tat[offset + 3]) - space); prevTextStop = offset == 0 ? 0 : tat[offset - 3]; nextTextStart = offset + 4 >= dataLength ? dataLength : tat[offset + 4]; middleIdx = ((nextTextStart - prevTextStop) - sourceLen) >> 1; } int target = prevTextStop + middleIdx; return target < 0 ? 0 : target; }
private void setInternal(int idx, byte[] source, int startFrom, int copyLength) { int offset = idx << 2; totalContent += (copyLength - (tat[offset + 1] - tat[offset])); int target = makeRoom(offset, copyLength); tat[offset] = target; tat[offset + 1] = target + copyLength; System.arraycopy(source, startFrom, data, target, copyLength); }
public void makeSpaceForAppend(int offset, int textLen) { int floor = offset - 3 >= 0 ? tat[offset - 3] : 0; int need = tat[offset + 1] + textLen - tat[offset]; if (need > (tat[offset + 4] - floor)) { makeRoom(offset, false, need); } // we have some space so just shift the existing data. int len = tat[offset + 1] - tat[offset]; System.arraycopy(data, tat[offset], data, floor, len); tat[offset] = floor; tat[offset + 1] = floor + len; }
private void setInternal(int idx, byte[] source, int startFrom, int copyLength) { int offset = idx << 2; totalContent += (copyLength - (tat[offset + 1] - tat[offset])); int target = makeRoom(offset, copyLength); tat[offset] = target; tat[offset + 1] = target + copyLength; System.arraycopy(source, startFrom, data, target, copyLength); }
public void makeSpaceForAppend(int offset, int textLen) { int floor = offset - 3 >= 0 ? tat[offset - 3] : 0; int need = tat[offset + 1] + textLen - tat[offset]; if (need > (tat[offset + 4] - floor)) { makeRoom(offset, false, need); } // we have some space so just shift the existing data. int len = tat[offset + 1] - tat[offset]; System.arraycopy(data, tat[offset], data, floor, len); tat[offset] = floor; tat[offset + 1] = floor + len; }
private void setInternal(int idx, byte[] source, int startFrom, int copyLength) { int offset = idx << 2; totalContent += (copyLength - (tat[offset + 1] - tat[offset])); int target = makeRoom(offset, copyLength); tat[offset] = target; tat[offset + 1] = target + copyLength; System.arraycopy(source, startFrom, data, target, copyLength); }
public void makeSpaceForAppend(int offset, int textLen) { int floor = offset - 3 >= 0 ? tat[offset - 3] : 0; int need = tat[offset + 1] + textLen - tat[offset]; if (need > (tat[offset + 4] - floor)) { makeRoom(offset, false, need); } // we have some space so just shift the existing data. int len = tat[offset + 1] - tat[offset]; System.arraycopy(data, tat[offset], data, floor, len); tat[offset] = floor; tat[offset + 1] = floor + len; }