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

@ -1501,45 +1501,36 @@ public void paste(int offset) {
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 { try {
endPos = getTibDoc().createPosition(end); DuffCode[] any_dc_array = new DuffCode[0];
i = start; DuffCode[] dc_array;
Position endPos = getTibDoc().createPosition(end);
int i = start;
java.util.List dcs = new ArrayList();
while (i < endPos.getOffset()+1) { while (i < endPos.getOffset()+1) {
attr = getTibDoc().getCharacterElement(i).getAttributes(); AttributeSet attr
fontName = StyleConstants.getFontFamily(attr); = getTibDoc().getCharacterElement(i).getAttributes();
String fontName = StyleConstants.getFontFamily(attr);
int fontNum;
if ((0 == (fontNum = TibetanMachineWeb.getTMWFontNumber(fontName))) || i==endPos.getOffset()) { if ((0 == (fontNum = TibetanMachineWeb.getTMWFontNumber(fontName))) || i==endPos.getOffset()) {
if (i != start) { if (i != start) {
dc_array = new DuffCode[0]; dc_array = (DuffCode[])dcs.toArray(any_dc_array);
dc_array = (DuffCode[])dcs.toArray(dc_array);
getTibDoc().remove(start, i-start); getTibDoc().remove(start, i-start);
append(start, TibTextUtils.getWylie(dc_array), romanAttributeSet); append(start, TibTextUtils.getWylie(dc_array), romanAttributeSet);
dcs.clear(); dcs.clear();
} }
start = i+1; start = i+1;
} } else {
else { char ch = getTibDoc().getText(i,1).charAt(0);
ch = getTibDoc().getText(i,1).charAt(0); dcs.add(new DuffCode(fontNum, ch));
dc = new DuffCode(fontNum, ch);
dcs.add(dc);
} }
i++; i++;
} }
} } catch (BadLocationException ble) {
catch (BadLocationException ble) {
ble.printStackTrace(); ble.printStackTrace();
ThdlDebug.noteIffyCode(); ThdlDebug.noteIffyCode();
} }