mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 21:11:28 +07:00
memory optimization: do not allocate empty arrays (part of KTIJ-27475 Investigate Kotlin plugin excessive memory usage)
GitOrigin-RevId: 25de43af6bcce77ad6507809b7cf83ae4e41b44b
This commit is contained in:
committed by
intellij-monorepo-bot
parent
6f3fae4c08
commit
32a0b64911
@@ -16,12 +16,12 @@ final class Component {
|
||||
final EKey @NotNull [] ids;
|
||||
|
||||
Component(@NotNull Value value, @NotNull Collection<EKey> ids) {
|
||||
this(value, ids.toArray(new EKey[0]));
|
||||
this(value, ids.toArray(EKey.EMPTY_ARRAY));
|
||||
}
|
||||
|
||||
Component(@NotNull Value value, EKey @NotNull ... ids) {
|
||||
this.value = value;
|
||||
this.ids = ids;
|
||||
this.ids = ids.length == 0 ? EKey.EMPTY_ARRAY : ids;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -7,6 +7,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
* Equation key (or variable)
|
||||
*/
|
||||
public final class EKey {
|
||||
public static final EKey[] EMPTY_ARRAY = new EKey[0];
|
||||
final @NotNull MemberDescriptor member;
|
||||
final int dirKey;
|
||||
final boolean stable;
|
||||
|
||||
@@ -373,7 +373,7 @@ abstract class EffectQuantum {
|
||||
CallQuantum(EKey key, DataValue[] data, boolean isStatic) {
|
||||
super((key.hashCode() * 31 + Arrays.hashCode(data)) * 31 + (isStatic ? 1 : 0));
|
||||
this.key = key;
|
||||
this.data = data;
|
||||
this.data = data.length == 0 ? DataValue.EMPTY : data;
|
||||
this.isStatic = isStatic;
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ final class ELattice<T extends Enum<T>> {
|
||||
|
||||
|
||||
class ResultUtil {
|
||||
private static final EKey[] EMPTY_PRODUCT = new EKey[0];
|
||||
private static final EKey[] EMPTY_PRODUCT = EKey.EMPTY_ARRAY;
|
||||
private final ELattice<Value> lattice;
|
||||
final Value top;
|
||||
final Value bottom;
|
||||
|
||||
@@ -14,7 +14,6 @@ import org.jetbrains.annotations.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -43,7 +42,7 @@ public final class FileTypeAssocTable<T> {
|
||||
myExactFileNameAnyCaseMappings = concurrentCharSequenceMapBuilder.build(exactFileNameAnyCaseMappings, false);
|
||||
myConcurrentCharSequenceMapBuilder = concurrentCharSequenceMapBuilder;
|
||||
myHashBangMap = new ConcurrentHashMap<>(hashBangMap);
|
||||
myMatchingMappings = new CopyOnWriteArrayList<>(matchingMappings);
|
||||
myMatchingMappings = ContainerUtil.createLockFreeCopyOnWriteList(matchingMappings);
|
||||
}
|
||||
|
||||
public FileTypeAssocTable(@NotNull ConcurrentCharSequenceMapBuilder<T> concurrentCharSequenceMapBuilder) {
|
||||
@@ -299,8 +298,8 @@ public final class FileTypeAssocTable<T> {
|
||||
}
|
||||
|
||||
// todo drop it, when ConcurrentCollectionFactory will be available in the classpath
|
||||
private static @NotNull <T> Map<CharSequence, T> createCharSequenceConcurrentMap(@NotNull Map<? extends CharSequence, ? extends T> source, boolean caseSensetive) {
|
||||
Map<CharSequence, T> map = CollectionFactory.createCharSequenceMap(caseSensetive, source.size(), 0.5f);
|
||||
private static @NotNull <T> Map<CharSequence, T> createCharSequenceConcurrentMap(@NotNull Map<? extends CharSequence, ? extends T> source, boolean caseSensitive) {
|
||||
Map<CharSequence, T> map = CollectionFactory.createCharSequenceMap(caseSensitive, source.size(), 0.5f);
|
||||
map.putAll(source);
|
||||
return Collections.synchronizedMap(map);
|
||||
}
|
||||
|
||||
@@ -60,8 +60,8 @@ final class ServiceModel implements Disposable, InvokerSupplier {
|
||||
|
||||
private final Project myProject;
|
||||
private final Invoker myInvoker = Invoker.forBackgroundThreadWithoutReadAction(this);
|
||||
private final List<ServiceViewItem> myRoots = new CopyOnWriteArrayList<>();
|
||||
private final List<ServiceModelEventListener> myListeners = new CopyOnWriteArrayList<>();
|
||||
private final List<ServiceViewItem> myRoots = ContainerUtil.createLockFreeCopyOnWriteList();
|
||||
private final List<ServiceModelEventListener> myListeners = ContainerUtil.createLockFreeCopyOnWriteList();
|
||||
|
||||
ServiceModel(@NotNull Project project) {
|
||||
myProject = project;
|
||||
|
||||
@@ -14,7 +14,7 @@ import java.util.function.Supplier
|
||||
class MergingQueueGuiSuspender {
|
||||
@Volatile
|
||||
private var myCurrentSuspender: ProgressSuspender? = null
|
||||
private val myRequestedSuspensions: MutableList<@NlsContexts.ProgressText String> = ContainerUtil.createEmptyCOWList()
|
||||
private val myRequestedSuspensions: MutableList<@NlsContexts.ProgressText String> = ContainerUtil.createConcurrentList()
|
||||
|
||||
fun suspendAndRun(activityName: @NlsContexts.ProgressText String, activity: Runnable) {
|
||||
heavyActivityStarted(activityName).use { activity.run() }
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
// Copyright 2000-2019 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.vcs.changes.ui
|
||||
|
||||
import com.intellij.util.ArrayUtilRt
|
||||
|
||||
class ChangeListRemoteState(size: Int) {
|
||||
// TODO BitSet suits here
|
||||
private val isUpToDateState = BooleanArray(size) { true }
|
||||
private val isUpToDateState = if (size == 0) ArrayUtilRt.EMPTY_BOOLEAN_ARRAY else BooleanArray(size) { true }
|
||||
|
||||
fun report(index: Int, isUpToDate: Boolean) {
|
||||
isUpToDateState[index] = isUpToDate
|
||||
|
||||
Reference in New Issue
Block a user