CR-IC-4094 (confusing methods united)

This commit is contained in:
Roman Shevchenko
2014-01-27 15:11:06 +04:00
parent e7106a442a
commit e2cdf406a3
9 changed files with 19 additions and 22 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2014 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.
@@ -95,7 +95,7 @@ public abstract class ClsElementImpl extends PsiElementBase implements PsiCompil
return PsiElement.EMPTY_ARRAY;
}
List<PsiElement> list = ContainerUtil.newArrayListWithExpectedSize(children.length);
List<PsiElement> list = ContainerUtil.newArrayListWithCapacity(children.length);
for (PsiElement child : children) {
if (child != null) {
list.add(child);
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2014 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.
@@ -150,7 +150,7 @@ public abstract class AbstractWizard<T extends Step> extends DialogWrapper {
final GroupLayout.SequentialGroup hGroup = layout.createSequentialGroup();
final GroupLayout.ParallelGroup vGroup = layout.createParallelGroup();
final Collection<Component> buttons = ContainerUtil.newArrayListWithExpectedSize(5);
final Collection<Component> buttons = ContainerUtil.newArrayListWithCapacity(5);
final boolean helpAvailable = ApplicationInfo.contextHelpAvailable();
if (helpAvailable && UIUtil.isUnderGTKLookAndFeel()) {
@@ -176,7 +176,7 @@ public class PersistentFSImpl extends PersistentFS implements ApplicationCompone
}
final TIntArrayList childrenIds = new TIntArrayList(current.length + toAdd.size());
final List<FSRecords.NameId> nameIds = ContainerUtil.newArrayListWithExpectedSize(current.length + toAdd.size());
final List<FSRecords.NameId> nameIds = ContainerUtil.newArrayListWithCapacity(current.length + toAdd.size());
for (FSRecords.NameId nameId : current) {
childrenIds.add(nameId.id);
nameIds.add(nameId);
@@ -56,7 +56,7 @@ public class AppUIUtil {
@SuppressWarnings({"UnnecessaryFullyQualifiedName", "deprecation"})
private static List<Image> getAppIconImages() {
ApplicationInfoEx appInfo = ApplicationInfoImpl.getShadowInstance();
List<Image> images = ContainerUtil.newArrayListWithExpectedSize(3);
List<Image> images = ContainerUtil.newArrayListWithCapacity(3);
if (SystemInfo.isXWindow) {
String bigIconUrl = appInfo.getBigIconUrl();
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2014 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.
@@ -152,7 +152,7 @@ public class MacFileChooserDialogImpl implements PathChooserDialog {
}
final LocalFileSystem fs = LocalFileSystem.getInstance();
final List<VirtualFile> files = ContainerUtil.newArrayListWithExpectedSize(paths.size());
final List<VirtualFile> files = ContainerUtil.newArrayListWithCapacity(paths.size());
for (String path : paths) {
final String vfsPath = FileUtil.toSystemIndependentName(path);
final VirtualFile file = fs.refreshAndFindFileByPath(vfsPath);
@@ -126,7 +126,7 @@ public class ContainerUtilRt {
@NotNull
public static <T> ArrayList<T> newArrayList(@NotNull T... elements) {
ArrayList<T> list = new ArrayList<T>(elements.length);
ArrayList<T> list = newArrayListWithCapacity(elements.length);
Collections.addAll(list, elements);
return list;
}
@@ -140,18 +140,14 @@ public class ContainerUtilRt {
return copy(ContainerUtilRt.<T>newArrayList(), elements);
}
@NotNull
/** @deprecated Use {@link #newArrayListWithCapacity(int)} (to remove in IDEA 15) */
public static <T> ArrayList<T> newArrayListWithExpectedSize(int size) {
return new ArrayList<T>(size);
return newArrayListWithCapacity(size);
}
@NotNull
public static <T> ArrayList<T> newArrayListWithCapacity(int size) {
return new ArrayList<T>(computeArrayListCapacity(size));
}
private static int computeArrayListCapacity(int size) {
return 5 + size + size / 5;
return new ArrayList<T>(size);
}
@NotNull
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2014 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.
@@ -45,7 +45,7 @@ public class CommandLineUtil {
// please keep an implementation in sync with [junit-rt] ProcessBuilder.createProcess()
@NotNull
public static List<String> toCommandLine(@NotNull String command, @NotNull List<String> parameters, @NotNull Platform platform) {
List<String> commandLine = ContainerUtil.newArrayListWithExpectedSize(parameters.size() + 1);
List<String> commandLine = ContainerUtil.newArrayListWithCapacity(parameters.size() + 1);
commandLine.add(FileUtilRt.toSystemDependentName(command, platform.fileSeparator));
@@ -150,9 +150,10 @@ public class ContainerUtil extends ContainerUtilRt {
return ContainerUtilRt.newArrayList(iterable);
}
@NotNull
/** @deprecated Use {@link #newArrayListWithCapacity(int)} (to remove in IDEA 15) */
@SuppressWarnings("deprecation")
public static <T> ArrayList<T> newArrayListWithExpectedSize(int size) {
return ContainerUtilRt.newArrayListWithExpectedSize(size);
return ContainerUtilRt.newArrayListWithCapacity(size);
}
@NotNull
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2014 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.
@@ -68,7 +68,7 @@ public class InjectorUtils {
InjectedLanguage.create(injection.getInjectedLanguageId(), injection.getPrefix(), injection.getSuffix(), false);
List<TextRange> ranges = injection.getInjectedArea(host);
List<Trinity<PsiLanguageInjectionHost, InjectedLanguage, TextRange>> list = ContainerUtil.newArrayListWithExpectedSize(ranges.size());
List<Trinity<PsiLanguageInjectionHost, InjectedLanguage, TextRange>> list = ContainerUtil.newArrayListWithCapacity(ranges.size());
for (TextRange range : ranges) {
list.add(Trinity.create(host, injectedLanguage, range));