From be39af2f20df534037cd0b37cff4ae84f9bf11b1 Mon Sep 17 00:00:00 2001 From: Bas Leijdekkers Date: Thu, 12 Apr 2018 16:50:44 +0200 Subject: [PATCH] CVS: save some memory while loading tags/branches --- .../cvsoperations/cvsLog/LogOperation.java | 30 ++++--------------- .../cvsTagOrBranch/TagsHelper.java | 18 ++--------- 2 files changed, 8 insertions(+), 40 deletions(-) diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/cvsLog/LogOperation.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/cvsLog/LogOperation.java index 67c80b17f13a..971e270b9622 100644 --- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/cvsLog/LogOperation.java +++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/cvsLog/LogOperation.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2009 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-2018 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.cvsSupport2.cvsoperations.cvsLog; import com.intellij.cvsSupport2.connections.CvsRootProvider; @@ -22,19 +8,19 @@ import com.intellij.cvsSupport2.cvsoperations.cvsTagOrBranch.BranchesProvider; import com.intellij.cvsSupport2.cvsoperations.cvsTagOrBranch.TagsHelper; import com.intellij.cvsSupport2.history.CvsRevisionNumber; import com.intellij.openapi.vcs.FilePath; +import gnu.trove.THashSet; import org.netbeans.lib.cvsclient.command.Command; import org.netbeans.lib.cvsclient.command.log.LogCommand; import org.netbeans.lib.cvsclient.command.log.LogInformation; -import java.util.ArrayList; import java.util.Collection; -import java.util.List; +import java.util.Set; /** * author: lesya */ public class LogOperation extends CvsOperationOnFiles implements BranchesProvider{ - private final List myLogInformationList = new ArrayList<>(); + private final Set branches = new THashSet<>(); public LogOperation(Collection files){ for (final FilePath file : files) { @@ -52,22 +38,18 @@ public class LogOperation extends CvsOperationOnFiles implements BranchesProvide public void fileInfoGenerated(Object info) { super.fileInfoGenerated(info); if (info instanceof LogInformation) { - myLogInformationList.add((LogInformation)info); + TagsHelper.collectBranches((LogInformation)info, branches); } } public Collection getAllBranches() { - return TagsHelper.getAllBranches(myLogInformationList); + return branches; } public Collection getAllRevisions() { return null; } - public List getLogInformationList() { - return myLogInformationList; - } - protected String getOperationName() { return "log"; } diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/cvsTagOrBranch/TagsHelper.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/cvsTagOrBranch/TagsHelper.java index af8a1beea868..2d828755ebb5 100644 --- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/cvsTagOrBranch/TagsHelper.java +++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/cvsTagOrBranch/TagsHelper.java @@ -1,18 +1,4 @@ -/* - * 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. - * 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-2018 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.cvsSupport2.cvsoperations.cvsTagOrBranch; import com.intellij.CvsBundle; @@ -97,7 +83,7 @@ public class TagsHelper { return branches; } - private static void collectBranches(LogInformation logInformation, HashSet branches) { + public static void collectBranches(LogInformation logInformation, Set branches) { final List allSymbolicNames = logInformation.getAllSymbolicNames(); for (final SymbolicName symbolicName : allSymbolicNames) { branches.add(symbolicName.getName());