Small TMW->Wylie performance improvements. TMW->Wylie is *much*

faster than TMW->Unicode etc.; this is because many fewer replacements
are made (i.e., more text is replaced each time a replacement is
performed).

I must find a way to still preserve formatting but do many fewer
replacements in TMW->{Unicode,TM} and TM->TMW.
This commit is contained in:
dchandler 2003-06-22 04:32:59 +00:00
parent 6540b260bd
commit 66287f3cc9

View file

@ -1497,53 +1497,44 @@ public void paste(int offset) {
* @param start the point from which to begin converting to Wylie * @param start the point from which to begin converting to Wylie
* @param end the point at which to stop converting to Wylie * @param end the point at which to stop converting to Wylie
*/ */
public void toWylie(int start, int end) { public void toWylie(int start, int end) {
if (start == end) if (start == end)
return; return;
DuffCode[] dc_array;
AttributeSet attr;
String fontName;
Position endPos;
int fontNum;
DuffCode dc;
char ch;
int i;
java.util.List dcs = new ArrayList(); try {
DuffCode[] any_dc_array = new DuffCode[0];
DuffCode[] dc_array;
Position endPos = getTibDoc().createPosition(end);
int i = start;
java.util.List dcs = new ArrayList();
try { while (i < endPos.getOffset()+1) {
endPos = getTibDoc().createPosition(end); AttributeSet attr
i = start; = getTibDoc().getCharacterElement(i).getAttributes();
String fontName = StyleConstants.getFontFamily(attr);
int fontNum;
while (i < endPos.getOffset()+1) { if ((0 == (fontNum = TibetanMachineWeb.getTMWFontNumber(fontName))) || i==endPos.getOffset()) {
attr = getTibDoc().getCharacterElement(i).getAttributes(); if (i != start) {
fontName = StyleConstants.getFontFamily(attr); dc_array = (DuffCode[])dcs.toArray(any_dc_array);
getTibDoc().remove(start, i-start);
append(start, TibTextUtils.getWylie(dc_array), romanAttributeSet);
dcs.clear();
}
start = i+1;
} else {
char ch = getTibDoc().getText(i,1).charAt(0);
dcs.add(new DuffCode(fontNum, ch));
}
if ((0 == (fontNum = TibetanMachineWeb.getTMWFontNumber(fontName))) || i==endPos.getOffset()) { i++;
if (i != start) { }
dc_array = new DuffCode[0]; } catch (BadLocationException ble) {
dc_array = (DuffCode[])dcs.toArray(dc_array); ble.printStackTrace();
getTibDoc().remove(start, i-start); ThdlDebug.noteIffyCode();
append(start, TibTextUtils.getWylie(dc_array), romanAttributeSet); }
dcs.clear(); }
}
start = i+1;
}
else {
ch = getTibDoc().getText(i,1).charAt(0);
dc = new DuffCode(fontNum, ch);
dcs.add(dc);
}
i++;
}
}
catch (BadLocationException ble) {
ble.printStackTrace();
ThdlDebug.noteIffyCode();
}
}
/** /**
* Converts a string of Extended Wylie to TibetanMachineWeb, and * Converts a string of Extended Wylie to TibetanMachineWeb, and