if (endStyle != null && ranges[j - 2] + ranges[j - 1] == endStart && endStyle.similarTo(styles[(j - 2) >> 1])) { ranges[j - 1] += endLength; modifyEnd += 2; mergeCount += 2; } if (rangeCount > modifyEnd) { System.arraycopy(ranges, modifyStart + mergeCount, ranges, j, rangeCount - modifyEnd); System.arraycopy(styles, (modifyStart + mergeCount) >> 1, styles, j >> 1, styleCount - (modifyEnd >> 1)); } grow = (j - modifyStart) - (modifyEnd - modifyStart);
int addMerge(int[] mergeRanges, StyleRange[] mergeStyles, int mergeCount, int modifyStart, int modifyEnd) {	int rangeCount = styleCount << 1;	StyleRange endStyle = null;	int endStart = 0, endLength = 0;	if (modifyEnd < rangeCount) {		endStyle = styles[modifyEnd >> 1];		endStart = ranges[modifyEnd];		endLength = ranges[modifyEnd + 1];	}	int grow = mergeCount - (modifyEnd - modifyStart);	if (rangeCount + grow >= ranges.length) {		int[] tmpRanges = new int[ranges.length + grow + (GROW << 1)];		System.arraycopy(ranges, 0, tmpRanges, 0, modifyStart);		StyleRange[] tmpStyles = new StyleRange[styles.length + (grow >> 1) + GROW];		System.arraycopy(styles, 0, tmpStyles, 0, modifyStart >> 1);		if (rangeCount > modifyEnd) {			System.arraycopy(ranges, modifyEnd, tmpRanges, modifyStart + mergeCount, rangeCount - modifyEnd);			System.arraycopy(styles, modifyEnd >> 1, tmpStyles, (modifyStart + mergeCount) >> 1, styleCount - (modifyEnd >> 1));		}		ranges = tmpRanges;		styles = tmpStyles;	} else {		if (rangeCount > modifyEnd) {			System.arraycopy(ranges, modifyEnd, ranges, modifyStart + mergeCount, rangeCount - modifyEnd);			System.arraycopy(styles, modifyEnd >> 1, styles, (modifyStart + mergeCount) >> 1, styleCount - (modifyEnd >> 1));		}	}		int j = modifyStart;		for (int i = 0; i < mergeCount; i += 2) {		if (j > 0 && ranges[j - 2] + ranges[j - 1] == mergeRanges[i] && mergeStyles[i >> 1].similarTo(styles[(j - 2) >> 1])) {			ranges[j - 1] += mergeRanges[i + 1];		} else {			styles[j >> 1] = mergeStyles[i >> 1];			ranges[j++] = mergeRanges[i];			ranges[j++] = mergeRanges[i + 1];		}	}	if (endStyle != null && ranges[j - 2] + ranges[j - 1] == endStart && endStyle.similarTo(styles[(j - 2) >> 1])) {		ranges[j - 1] += endLength;		modifyEnd += 2;		mergeCount += 2;	}	if (rangeCount > modifyEnd) {		System.arraycopy(ranges, modifyStart + mergeCount, ranges, j, rangeCount - modifyEnd);		System.arraycopy(styles, (modifyStart + mergeCount) >> 1, styles, j >> 1, styleCount - (modifyEnd >> 1));	}	grow = (j - modifyStart) - (modifyEnd - modifyStart);	styleCount += grow >> 1;	return grow;}