mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Faster leaf node search CR-IU-897
This commit is contained in:
@@ -163,21 +163,28 @@ public class CompositeElement extends TreeElement {
|
||||
startFind:
|
||||
while (true) {
|
||||
TreeElement child = element.getFirstChildNode();
|
||||
TreeElement lastChild = element.getLastChildNode();
|
||||
boolean fwd = lastChild == null || (lastChild.getStartOffset() + lastChild.getTextLength() - child.getStartOffset()) / 2 > offset;
|
||||
if (!fwd) {
|
||||
child = lastChild;
|
||||
offset = element.getTextLength() - offset;
|
||||
}
|
||||
while (child != null) {
|
||||
final int textLength = child.getTextLength();
|
||||
if (textLength > offset) {
|
||||
if (textLength > offset || !fwd && textLength >= offset) {
|
||||
if (child instanceof LeafElement) {
|
||||
if (child instanceof ForeignLeafPsiElement) {
|
||||
child = child.getTreeNext();
|
||||
child = fwd ? child.getTreeNext() : child.getTreePrev();
|
||||
continue;
|
||||
}
|
||||
return (LeafElement)child;
|
||||
}
|
||||
offset = fwd ? offset : child.getTextLength() - offset;
|
||||
element = child;
|
||||
continue startFind;
|
||||
}
|
||||
offset -= textLength;
|
||||
child = child.getTreeNext();
|
||||
child = fwd ? child.getTreeNext() : child.getTreePrev();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user