Skip to content

Commit 3d71739

Browse files
piotrtomiakintellij-monorepo-bot
authored andcommitted
WEB-61150 CharSequenceSubSequence: improve documentation.
GitOrigin-RevId: cae617a6744de40165aa8884906469811013e1d1
1 parent 6771ac0 commit 3d71739

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

platform/util/base/src/com/intellij/util/text/CharSequenceSubSequence.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@
1212
* creation of a new char array on every {@code subSequence(int, int)} call in contrast to {@link String#subSequence(int, int)},
1313
* which actually creates a new {@link String} instance every time it's invoked.
1414
* <p>
15+
* The downside of using {@code CharSequenceSubSequence} is that it keeps reference to the original sequence, which may be large.
16+
* Therefore, results of text processing should always be stored as {@link String}, to allow garbage collection of the original sequence.
17+
* <p>
1518
* {@code CharSequenceSubSequence} implements `hashCode` and `equals` in such a way that it can be compared against {@link String} map keys
1619
* and set elements without creating a {@link String} instance. However, {@code CharSequenceSubSequence} should not be used
17-
* as a map key or set element, since {@link CharSequence} API does not guarantee anything beside char iteration.
18-
* <p>
19-
* Results of text processing should always be stored as {@link String}.
20+
* as a map key or set element, since it keeps reference to the original sequence and prevents its collection.
2021
**/
2122
public class CharSequenceSubSequence implements CharSequence, CharArrayExternalizable, CharSequenceWithStringHash {
2223
private final CharSequence myChars;

0 commit comments

Comments
 (0)