mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-10-06 06:21:16 +07:00
avoid arrayList allocation
This commit is contained in:
@@ -1,17 +1,5 @@
|
||||
/*
|
||||
* 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
*/
|
||||
package com.intellij.openapi.roots.impl;
|
||||
|
||||
@@ -206,7 +194,7 @@ public abstract class RootModelBase implements ModuleRootModel {
|
||||
@NotNull
|
||||
public Module[] getModuleDependencies(boolean includeTests) {
|
||||
OrderEntry[] entries = getOrderEntries();
|
||||
List<Module> result = new ArrayList<>(entries.length);
|
||||
List<Module> result = null;
|
||||
|
||||
for (OrderEntry entry : entries) {
|
||||
if (entry instanceof ModuleOrderEntry) {
|
||||
@@ -214,13 +202,16 @@ public abstract class RootModelBase implements ModuleRootModel {
|
||||
if (includeTests || scope.isForProductionCompile() || scope.isForProductionRuntime()) {
|
||||
Module module = ((ModuleOrderEntry)entry).getModule();
|
||||
if (module != null) {
|
||||
if (result == null) {
|
||||
result = new SmartList<>();
|
||||
}
|
||||
result.add(module);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result.isEmpty() ? Module.EMPTY_ARRAY : ContainerUtil.toArray(result, new Module[result.size()]);
|
||||
return result == null ? Module.EMPTY_ARRAY : ContainerUtil.toArray(result, new Module[result.size()]);
|
||||
}
|
||||
|
||||
private static class CollectDependentModules extends RootPolicy<List<String>> {
|
||||
|
||||
Reference in New Issue
Block a user