Call to 'list.containsAll(collection)' may have poor performance
Reports calls to containsAll()
on java.util.List
.
The time complexity of this method call is O(n·m), where n is the number of elements in the list on which the method is called, and m is the number of elements in the collection passed to the method as a parameter. When the list is large, this can be an expensive operation.
The quick-fix wraps the list in new java.util.HashSet<>()
since the time required to create java.util.HashSet
from java.util.List
and execute containsAll()
on java.util.HashSet
is O(n+m).
Example:
After the quick-fix is applied:
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.
SlowListContainsAll- 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.
New in 2022.1
Inspection Details | |
---|---|
By default bundled with: | |
Can be installed with plugin: | Java, 242.22892 |