Skip to content

Commit 645c105

Browse files
authored
Refactor PubRoots to use SmartList usage patterns (#8676)
SmartList is a memory-efficient List implementation in the IntelliJ Platform, optimized for collections that typically contain 0 or 1 element. This change updates PubRoots to use SmartList for collecting pub roots from modules and projects, as these lists are often small.
1 parent f61d7c7 commit 645c105

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/io/flutter/pub/PubRoots.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import io.flutter.utils.OpenApiUtils;
1212
import org.jetbrains.annotations.NotNull;
1313

14-
import java.util.ArrayList;
14+
import com.intellij.util.SmartList;
1515
import java.util.List;
1616

1717
/**
@@ -29,7 +29,7 @@ private PubRoots() {
2929
*/
3030
@NotNull
3131
public static List<@NotNull PubRoot> forModule(@NotNull Module module) {
32-
final List<PubRoot> result = new ArrayList<>();
32+
final List<PubRoot> result = new SmartList<>();
3333
if (module.isDisposed()) return result;
3434

3535
for (VirtualFile dir : OpenApiUtils.getContentRoots(module)) {
@@ -48,7 +48,7 @@ private PubRoots() {
4848
*/
4949
@NotNull
5050
public static List<@NotNull PubRoot> forProject(@NotNull Project project) {
51-
final List<PubRoot> result = new ArrayList<>();
51+
final List<PubRoot> result = new SmartList<>();
5252
if (project.isDisposed()) return result;
5353

5454
for (Module module : OpenApiUtils.getModules(project)) {

0 commit comments

Comments
 (0)