Added javadoc with optimization clarification

IJ-CR-114841

GitOrigin-RevId: ba30d234673429dd9cab378578c1c511d144d01e
This commit is contained in:
Alexandr Evstigneev
2023-09-26 13:34:40 +00:00
committed by intellij-monorepo-bot
parent c1b7050f41
commit 091b261d23
@@ -201,6 +201,11 @@ public class CompositeElement extends TreeElement {
return TreeUtil.findSibling(anchor, typesSet);
}
/**
* @implNote Optimization. Instead of just calling new {@code String(textToCharArray())} we try to delegate the text computation to the
* first child, if there's only one, in hope it has optimized its own {@code getText()} and we thus can skip allocating buffer in
* {@link AstBufferUtil}
*/
@Override
public @NotNull String getText() {
TreeElement firstChildNode = getFirstChildNode();