int modifyEnd = modifyStart; if (modifyStart == rangeCount) {
int modifyEnd = getRangeIndex(end, modifyStart - 1, rangeCount); if (modifyStart == modifyEnd) {
void setStyleRanges (int[] newRanges, StyleRange[] newStyles) {	if (newStyles == null) {		stylesSetCount = styleCount = 0;		ranges = null;		styles = null;		stylesSet = null;		return;	}	if (newRanges == null && NEW_DB) {		newRanges = new int[newStyles.length << 1];				StyleRange[] tmpStyles = new StyleRange[newStyles.length];		if (stylesSet == null) stylesSet = new StyleRange[4];		for (int i = 0, j = 0; i < newStyles.length; i++) {			StyleRange newStyle = newStyles[i];			newRanges[j++] = newStyle.start;			newRanges[j++] = newStyle.length;			int index = 0;			while (index < stylesSetCount) {				if (stylesSet[index].similarTo(newStyle)) break;				index++;			}			if (index == stylesSetCount) {				if (stylesSetCount == stylesSet.length) {					StyleRange[] tmpStylesSet = new StyleRange[stylesSetCount + 4];					System.arraycopy(stylesSet, 0, tmpStylesSet, 0, stylesSetCount);					stylesSet = tmpStylesSet;				}				stylesSet[stylesSetCount++] = newStyle;			}			tmpStyles[i] = stylesSet[index];		}		newStyles = tmpStyles;	}		if (styleCount == 0) {		if (newRanges != null) {			ranges = new int[newRanges.length];			System.arraycopy(newRanges, 0, ranges, 0, ranges.length);		}		styles = new StyleRange[newStyles.length];		System.arraycopy(newStyles, 0, styles, 0, styles.length);		styleCount = newStyles.length;		return;	}	if (newRanges != null && ranges == null) {		ranges = new int[styles.length << 1];		for (int i = 0, j = 0; i < styleCount; i++) {			ranges[j++] = styles[i].start;			ranges[j++] = styles[i].length;		}	}	if (newRanges == null && ranges != null) {		newRanges = new int[newStyles.length << 1];		for (int i = 0, j = 0; i < newStyles.length; i++) {			newRanges[j++] = newStyles[i].start;			newRanges[j++] = newStyles[i].length;		}	}	if (ranges != null) {		int start = newRanges[0];		int rangeCount = styleCount << 1;		int modifyStart = getRangeIndex(start, -1, rangeCount);		int modifyEnd = modifyStart;		if (modifyStart == rangeCount) {			addMerge(newRanges, newStyles, newRanges.length, modifyStart, modifyEnd);			return;		}		int[] mergeRanges = new int[6];		StyleRange[] mergeStyles = new StyleRange[3];		for (int i = 0; i < newRanges.length; i += 2) {			int newStart = newRanges[i];			int newEnd = newStart + newRanges[i + 1];			if (newStart == newEnd) continue;			int modifyLast = 0, mergeCount = 0;			while (modifyEnd < rangeCount) {				if (newStart >= ranges[modifyStart] + ranges[modifyStart + 1]) modifyStart += 2;				if (ranges[modifyEnd] + ranges[modifyEnd + 1] > newEnd) break;				modifyEnd += 2;			}			if (ranges[modifyStart] < newStart && newStart < ranges[modifyStart] + ranges[modifyStart + 1]) {				mergeStyles[mergeCount >> 1] = styles[modifyStart >> 1];				mergeRanges[mergeCount] = ranges[modifyStart];				mergeRanges[mergeCount + 1] = newStart - ranges[modifyStart];								mergeCount += 2;			}			mergeStyles[mergeCount >> 1] = newStyles[i >> 1];			mergeRanges[mergeCount] = newStart;			mergeRanges[mergeCount + 1] = newRanges[i + 1];			mergeCount += 2;			if (modifyEnd < rangeCount && ranges[modifyEnd] < newEnd && newEnd < ranges[modifyEnd] + ranges[modifyEnd + 1]) {				mergeStyles[mergeCount >> 1] = styles[modifyEnd >> 1];				mergeRanges[mergeCount] = newEnd;				mergeRanges[mergeCount + 1] = ranges[modifyEnd] + ranges[modifyEnd + 1] - newEnd;				mergeCount += 2;				modifyLast = 2;			}			int grow = addMerge(mergeRanges, mergeStyles, mergeCount, modifyStart, modifyEnd + modifyLast);			rangeCount += grow;			modifyStart = modifyEnd += grow;		}	} else {		int start = newStyles[0].start;		int modifyStart = getRangeIndex(start, -1, styleCount);		int modifyEnd = modifyStart;		if (modifyStart == styleCount) {			addMerge(newStyles, newStyles.length, modifyStart, modifyEnd);			return;		}		StyleRange[] mergeStyles = new StyleRange[3];		for (int i = 0; i < newStyles.length; i++) {			StyleRange newStyle = newStyles[i], style; 			int newStart = newStyle.start;			int newEnd = newStart + newStyle.length;			if (newStart == newEnd) continue;			int modifyLast = 0, mergeCount = 0;			while (modifyEnd < styleCount) {				if (newStart >= styles[modifyStart].start + styles[modifyStart].length) modifyStart++;				if (styles[modifyEnd].start + styles[modifyEnd].length > newEnd) break;				modifyEnd++;			}			style = styles[modifyStart];			if (style.start < newStart && newStart < style.start + style.length) {				style = mergeStyles[mergeCount++] = (StyleRange)style.clone();				style.length = newStart - style.start;			}			mergeStyles[mergeCount++] = newStyle;			if (modifyEnd < styleCount) {				style = styles[modifyEnd];				if (style.start < newEnd && newEnd < style.start + style.length) {					style = mergeStyles[mergeCount++] = (StyleRange)style.clone();					style.length += style.start - newEnd;					style.start = newEnd;					modifyLast = 1;				}			}			int grow = addMerge(mergeStyles, mergeCount, modifyStart, modifyEnd + modifyLast);			modifyStart = modifyEnd += grow;		}	}}