diff --git a/platform/core-impl/src/com/intellij/psi/impl/source/tree/CompositeElement.java b/platform/core-impl/src/com/intellij/psi/impl/source/tree/CompositeElement.java index d5fe39f01ec2..ada7fb31807e 100644 --- a/platform/core-impl/src/com/intellij/psi/impl/source/tree/CompositeElement.java +++ b/platform/core-impl/src/com/intellij/psi/impl/source/tree/CompositeElement.java @@ -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();