mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
a less gc-producing ImmutableText.subtext
This commit is contained in:
@@ -97,7 +97,7 @@ public final class ImmutableText extends ImmutableCharSequence implements CharAr
|
||||
}
|
||||
|
||||
private ImmutableText ensureChunked() {
|
||||
if (length() >= BLOCK_SIZE && myNode instanceof LeafNode) {
|
||||
if (length() > BLOCK_SIZE && myNode instanceof LeafNode) {
|
||||
return new ImmutableText(nodeOf(((LeafNode)myNode)._data, 0, length()));
|
||||
}
|
||||
return this;
|
||||
@@ -402,6 +402,9 @@ public final class ImmutableText extends ImmutableCharSequence implements CharAr
|
||||
|
||||
@Override
|
||||
Node subNode(int start, int end) {
|
||||
if (start == 0 && end == nodeLength()) {
|
||||
return this;
|
||||
}
|
||||
int length = end - start;
|
||||
char[] chars = new char[length];
|
||||
System.arraycopy(_data, start, chars, 0, length);
|
||||
@@ -467,6 +470,8 @@ public final class ImmutableText extends ImmutableCharSequence implements CharAr
|
||||
return _head.subNode(start, end);
|
||||
if (start >= cesure)
|
||||
return _tail.subNode(start - cesure, end - cesure);
|
||||
if ((start == 0) && (end == _count))
|
||||
return this;
|
||||
// Overlaps head and tail.
|
||||
return _head.subNode(start, cesure).concatNodes(_tail.subNode(0, end - cesure));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user