From 091b261d23fec26ed16b7f43913d8ea4927e608d Mon Sep 17 00:00:00 2001 From: Alexandr Evstigneev Date: Tue, 26 Sep 2023 17:11:04 +0400 Subject: [PATCH] Added javadoc with optimization clarification IJ-CR-114841 GitOrigin-RevId: ba30d234673429dd9cab378578c1c511d144d01e --- .../com/intellij/psi/impl/source/tree/CompositeElement.java | 5 +++++ 1 file changed, 5 insertions(+) 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();