Call chain on collection could be converted into 'Sequence' to improve performance
Reports call chain on a Collection that should be converted into Sequence.
Each Collection transforming function (such as map() or filter()) creates a new Collection (typically List or Set) under the hood. In case of multiple consequent calls, and a huge number of items in Collection, memory traffic might be significant. In such a case, using Sequence is preferred.
Example:
The quick-fix wraps call chain into asSequence() and toList():
Locating this inspection
- By ID
Can be used to locate inspection in e.g. Qodana configuration files, where you can quickly enable or disable it, or adjust its settings.
ConvertCallChainIntoSequence- Via Settings dialog
Path to the inspection settings via IntelliJ Platform IDE Settings dialog, when you need to adjust inspection settings directly from your IDE.
Inspection options
Here you can find the description of settings available for the Call chain on collection could be converted into 'Sequence' to improve performance inspection, and the reference of their default values.
- Call chain length to transform
Default value:
5
Suppressing Inspection
You can suppress this inspection by placing the following comment marker before the code fragment where you no longer want messages from this inspection to appear:
More detailed instructions as well as other ways and options that you have can be found in the product documentation:
Inspection Details | |
|---|---|
By default bundled with: |