From 0d71a383ce67983ebb131655a6ab4cbb7a710ae3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yann=20C=C3=A9bron?= Date: Mon, 18 May 2015 18:33:56 +0200 Subject: [PATCH] FinderRecursivePanel#mergeListItems: optimize when adding items to empty list (initial population) --- .../src/com/intellij/ui/FinderRecursivePanel.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/ui/FinderRecursivePanel.java b/platform/platform-impl/src/com/intellij/ui/FinderRecursivePanel.java index 6014cb829993..c3943d0f31d3 100644 --- a/platform/platform-impl/src/com/intellij/ui/FinderRecursivePanel.java +++ b/platform/platform-impl/src/com/intellij/ui/FinderRecursivePanel.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -533,7 +533,13 @@ public abstract class FinderRecursivePanel extends JBSplitter implements Data }); } - public static void mergeListItems(@NotNull CollectionListModel listModel, @NotNull List newItems) { + static void mergeListItems(@NotNull CollectionListModel listModel, @NotNull List newItems) { + boolean isEmptyList = listModel.getSize() == 0; + if (isEmptyList) { + listModel.add(newItems); + return; + } + // remove items for (int i = listModel.getSize() - 1; i >= 0; i--) { if (!newItems.contains(listModel.getElementAt(i))) { @@ -574,7 +580,8 @@ public abstract class FinderRecursivePanel extends JBSplitter implements Data final FinderRecursivePanel childPanel = (FinderRecursivePanel)myChild; if (withUpdatePanel) { childPanel.init(); - } else { + } + else { childPanel.initWithoutUpdatePanel(); } }