mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
use IdentityHashMap, its get is faster than THashMap's
This commit is contained in:
+2
-6
@@ -22,7 +22,6 @@ import com.intellij.util.ProcessingContext;
|
||||
import com.intellij.util.SmartList;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.MultiMap;
|
||||
import gnu.trove.THashMap;
|
||||
import gnu.trove.THashSet;
|
||||
import gnu.trove.TObjectHashingStrategy;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -35,8 +34,8 @@ import java.util.*;
|
||||
public class LiftShorterItemsClassifier extends Classifier<LookupElement> {
|
||||
private final TreeSet<String> mySortedStrings = new TreeSet<String>();
|
||||
private final MultiMap<String, LookupElement> myElements = new MultiMap<String, LookupElement>();
|
||||
private final Map<LookupElement, Set<LookupElement>> myToLiftForSorting = new THashMap<LookupElement, Set<LookupElement>>(TObjectHashingStrategy.IDENTITY);
|
||||
private final Map<LookupElement, Set<LookupElement>> myToLiftForPreselection = new THashMap<LookupElement, Set<LookupElement>>(TObjectHashingStrategy.IDENTITY);
|
||||
private final Map<LookupElement, Set<LookupElement>> myToLiftForSorting = new IdentityHashMap<LookupElement, Set<LookupElement>>();
|
||||
private final Map<LookupElement, Set<LookupElement>> myToLiftForPreselection = new IdentityHashMap<LookupElement, Set<LookupElement>>();
|
||||
private final MultiMap<String, String> myPrefixes = new MultiMap<String, String>();
|
||||
private final Classifier<LookupElement> myNext;
|
||||
private final LiftingCondition myCondition;
|
||||
@@ -127,9 +126,7 @@ public class LiftShorterItemsClassifier extends Classifier<LookupElement> {
|
||||
boolean forSorting = context.get(CompletionLookupArranger.PURE_RELEVANCE) != Boolean.TRUE;
|
||||
final List<LookupElement> result = new ArrayList<LookupElement>();
|
||||
for (LookupElement element : myNext.classify(source, context)) {
|
||||
assert srcSet.contains(element) : myNext;
|
||||
if (processed.add(element)) {
|
||||
//System.out.println("element = " + element);
|
||||
List<LookupElement> shorter = addShorterElements(srcSet, processed, null, myToLiftForPreselection.get(element));
|
||||
if (forSorting) {
|
||||
shorter = addShorterElements(srcSet, processed, shorter, myToLiftForSorting.get(element));
|
||||
@@ -151,7 +148,6 @@ public class LiftShorterItemsClassifier extends Classifier<LookupElement> {
|
||||
@Nullable Set<LookupElement> from) {
|
||||
if (from != null) {
|
||||
for (LookupElement shorterElement : from) {
|
||||
//System.out.println("shorterElement = " + shorterElement);
|
||||
if (srcSet.contains(shorterElement) && processed.add(shorterElement)) {
|
||||
if (toLift == null) toLift = new SmartList<LookupElement>();
|
||||
toLift.add(shorterElement);
|
||||
|
||||
+2
-3
@@ -17,17 +17,16 @@ package com.intellij.codeInsight.lookup;
|
||||
|
||||
import com.intellij.psi.ForceableComparable;
|
||||
import com.intellij.util.ProcessingContext;
|
||||
import gnu.trove.THashMap;
|
||||
import gnu.trove.TObjectHashingStrategy;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author peter
|
||||
*/
|
||||
public class CachingComparingClassifier extends ComparingClassifier<LookupElement> {
|
||||
private final Map<LookupElement, Comparable> myWeights = new THashMap<LookupElement, Comparable>(TObjectHashingStrategy.IDENTITY);
|
||||
private final Map<LookupElement, Comparable> myWeights = new IdentityHashMap<LookupElement, Comparable>();
|
||||
private final LookupElementWeigher myWeigher;
|
||||
private Comparable myFirstWeight;
|
||||
private boolean myPrimitive = true;
|
||||
|
||||
Reference in New Issue
Block a user