From 306802da69956efdb0fdf2227886d0cbcc729f4e Mon Sep 17 00:00:00 2001 From: Aleksey Pivovarov Date: Tue, 31 Jan 2017 19:03:42 +0300 Subject: [PATCH] vcs: move data from LocalChangeListImpl to the ChangeListWorker --- .../openapi/vcs/changes/ChangeListWorker.java | 13 ++++++++----- .../openapi/vcs/changes/LocalChangeListImpl.java | 15 --------------- 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangeListWorker.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangeListWorker.java index d75f29339eae..ee86909725f3 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangeListWorker.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangeListWorker.java @@ -57,6 +57,8 @@ public class ChangeListWorker implements ChangeListsWriteOperations { private final ChangesDelta myDelta; private final Set myListsToDisappear; + private final Map> myChangesBeforeUpdateMap = new HashMap<>(); + public ChangeListWorker(final Project project, final PlusMinusModify deltaListener) { myProject = project; myMap = new LinkedHashMap<>(); @@ -237,7 +239,8 @@ public class ChangeListWorker implements ChangeListsWriteOperations { LOG.debug("[addChangeToCorrespondingList] for change " + path + " type: " + change.getType() + " have before revision: " + (change.getBeforeRevision() != null)); assert myDefault != null; for (LocalChangeListImpl list : myMap.values()) { - if (list.getChangesBeforeUpdate().contains(change)) { + OpenTHashSet changesBeforeUpdate = myChangesBeforeUpdateMap.get(list); + if (changesBeforeUpdate.contains(change)) { LOG.debug("[addChangeToCorrespondingList] matched: " + list.getName()); list.addChange(change); myIdx.changeAdded(change, vcsKey); @@ -393,11 +396,13 @@ public class ChangeListWorker implements ChangeListsWriteOperations { } } myListsToDisappear.clear(); + + myChangesBeforeUpdateMap.clear(); } private Collection startProcessingChanges(@NotNull LocalChangeListImpl list, @Nullable final VcsDirtyScope scope) { OpenTHashSet changesBeforeUpdate = new OpenTHashSet<>(list.getChanges()); - list.setChangesBeforeUpdate(changesBeforeUpdate); + myChangesBeforeUpdateMap.put(list, changesBeforeUpdate); final Collection result = new ArrayList<>(); for (Change oldBoy : changesBeforeUpdate) { @@ -429,7 +434,7 @@ public class ChangeListWorker implements ChangeListsWriteOperations { } private boolean doneProcessingChanges(@NotNull LocalChangeListImpl list, List removedChanges, List addedChanges) { - OpenTHashSet changesBeforeUpdate = list.getChangesBeforeUpdate(); + OpenTHashSet changesBeforeUpdate = myChangesBeforeUpdateMap.get(list); Set changes = list.getChanges(); boolean changesDetected = (changes.size() != changesBeforeUpdate.size()); @@ -446,8 +451,6 @@ public class ChangeListWorker implements ChangeListsWriteOperations { removedChanges.addAll(removed); changesDetected = changesDetected || (!removedChanges.isEmpty()); - list.setChangesBeforeUpdate(null); - return changesDetected; } diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/LocalChangeListImpl.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/LocalChangeListImpl.java index 57ba67abf879..35c19d7442e1 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/LocalChangeListImpl.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/LocalChangeListImpl.java @@ -5,11 +5,9 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.util.registry.Registry; import com.intellij.openapi.util.text.StringUtil; import com.intellij.util.containers.ContainerUtil; -import com.intellij.util.containers.OpenTHashSet; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.Collection; import java.util.Collections; import java.util.Set; import java.util.UUID; @@ -30,7 +28,6 @@ public class LocalChangeListImpl extends LocalChangeList { private boolean myIsDefault = false; private boolean myIsReadOnly = false; - private OpenTHashSet myChangesBeforeUpdate; @NotNull public static LocalChangeListImpl createEmptyChangeListImpl(@NotNull Project project, @NotNull String name, @Nullable String id) { @@ -57,10 +54,6 @@ public class LocalChangeListImpl extends LocalChangeList { myChanges = ContainerUtil.newHashSet(origin.myChanges); - if (myChangesBeforeUpdate != null) { - myChangesBeforeUpdate = new OpenTHashSet<>((Collection)origin.myChangesBeforeUpdate); - } - if (myReadChangesCache != null) { myReadChangesCache = origin.myReadChangesCache; } @@ -156,14 +149,6 @@ public class LocalChangeListImpl extends LocalChangeList { return null; } - void setChangesBeforeUpdate(OpenTHashSet changesBeforeUpdate) { - myChangesBeforeUpdate = changesBeforeUpdate; - } - - OpenTHashSet getChangesBeforeUpdate() { - return myChangesBeforeUpdate; - } - public boolean equals(final Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false;