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:
parent
6540b260bd
commit
66287f3cc9
1 changed files with 33 additions and 42 deletions
|
@ -1501,45 +1501,36 @@ public void paste(int offset) {
|
|||
if (start == end)
|
||||
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 {
|
||||
endPos = getTibDoc().createPosition(end);
|
||||
i = start;
|
||||
DuffCode[] any_dc_array = new DuffCode[0];
|
||||
DuffCode[] dc_array;
|
||||
Position endPos = getTibDoc().createPosition(end);
|
||||
int i = start;
|
||||
java.util.List dcs = new ArrayList();
|
||||
|
||||
while (i < endPos.getOffset()+1) {
|
||||
attr = getTibDoc().getCharacterElement(i).getAttributes();
|
||||
fontName = StyleConstants.getFontFamily(attr);
|
||||
AttributeSet attr
|
||||
= getTibDoc().getCharacterElement(i).getAttributes();
|
||||
String fontName = StyleConstants.getFontFamily(attr);
|
||||
int fontNum;
|
||||
|
||||
if ((0 == (fontNum = TibetanMachineWeb.getTMWFontNumber(fontName))) || i==endPos.getOffset()) {
|
||||
if (i != start) {
|
||||
dc_array = new DuffCode[0];
|
||||
dc_array = (DuffCode[])dcs.toArray(dc_array);
|
||||
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 {
|
||||
ch = getTibDoc().getText(i,1).charAt(0);
|
||||
dc = new DuffCode(fontNum, ch);
|
||||
dcs.add(dc);
|
||||
} else {
|
||||
char ch = getTibDoc().getText(i,1).charAt(0);
|
||||
dcs.add(new DuffCode(fontNum, ch));
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
}
|
||||
catch (BadLocationException ble) {
|
||||
} catch (BadLocationException ble) {
|
||||
ble.printStackTrace();
|
||||
ThdlDebug.noteIffyCode();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue