From b3e99ae1a40a57d499164be0e0a71683cd4a07df Mon Sep 17 00:00:00 2001 From: peter Date: Tue, 22 Oct 2013 21:11:25 +0200 Subject: [PATCH] remove ConcurrentSoftArrayHashMap --- .../ConcurrentSoftArrayHashMap.java | 130 ------------------ .../intellij/util/xml/ModelMergerImpl.java | 13 -- 2 files changed, 143 deletions(-) delete mode 100644 platform/util/src/com/intellij/util/containers/ConcurrentSoftArrayHashMap.java diff --git a/platform/util/src/com/intellij/util/containers/ConcurrentSoftArrayHashMap.java b/platform/util/src/com/intellij/util/containers/ConcurrentSoftArrayHashMap.java deleted file mode 100644 index b988b3fa6134..000000000000 --- a/platform/util/src/com/intellij/util/containers/ConcurrentSoftArrayHashMap.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright 2000-2013 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. - */ - -package com.intellij.util.containers; - -import com.intellij.reference.SoftReference; -import gnu.trove.TObjectHashingStrategy; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.Map; - -/** - * @author peter - */ -public class ConcurrentSoftArrayHashMap implements Cloneable { - private ConcurrentSoftHashMap> myContinuationMap; - private ConcurrentSoftHashMap> myValuesMap; - private SoftReference myValueForEmptyArray; - private final TObjectHashingStrategy myStrategy; - - public ConcurrentSoftArrayHashMap() { - this(ContainerUtil.canonicalStrategy()); - } - - public ConcurrentSoftArrayHashMap(@NotNull TObjectHashingStrategy strategy) { - myStrategy = strategy; - } - - @Nullable - private V get(T[] array, int index) { - if (index == array.length - 1) { - final ConcurrentSoftHashMap> valuesMap = myValuesMap; - if (valuesMap != null) { - final SoftReference softReference = valuesMap.get(array[index]); - if (softReference != null) { - return softReference.get(); - } - } - return null; - } - - final ConcurrentSoftHashMap> continuationMap = myContinuationMap; - if (continuationMap != null) { - final ConcurrentSoftArrayHashMap map = continuationMap.get(array[index]); - if (map != null) { - return map.get(array, index + 1); - } - } - - return null; - } - - @Nullable - public final V get(T[] key) { - if (key.length == 0) { - final SoftReference emptyValue = myValueForEmptyArray; - return emptyValue == null ? null : emptyValue.get(); - } - return get(key, 0); - } - - private void put(T[] array, int index, V value) { - final T key = array[index]; - if (index == array.length - 1) { - if (myValuesMap == null) { - myValuesMap = new ConcurrentSoftHashMap>(myStrategy); - } - myValuesMap.put(key, new SoftReference(value)); - } else { - if (myContinuationMap == null) { - myContinuationMap = new ConcurrentSoftHashMap>(myStrategy); - } - ConcurrentSoftArrayHashMap softArrayHashMap = myContinuationMap.get(key); - if (softArrayHashMap == null) { - myContinuationMap.put(key, softArrayHashMap = new ConcurrentSoftArrayHashMap(myStrategy)); - } - softArrayHashMap.put(array, index + 1, value); - } - } - - public final synchronized void put(T[] key, V value) { - if (key.length == 0) { - myValueForEmptyArray = new SoftReference(value); - } - else { - put(key, 0, value); - } - } - - public final synchronized void clear() { - myContinuationMap = null; - myValuesMap = null; - myValueForEmptyArray = null; - } - - public final boolean containsKey(final T[] path) { - return get(path) != null; - } - - @Override - public final synchronized ConcurrentSoftArrayHashMap clone() { - final ConcurrentSoftArrayHashMap copy = new ConcurrentSoftArrayHashMap(myStrategy); - copy.myContinuationMap = copyMap(myContinuationMap); - copy.myValuesMap = copyMap(myValuesMap); - copy.myValueForEmptyArray = myValueForEmptyArray; - return copy; - } - - private ConcurrentSoftHashMap copyMap(final ConcurrentSoftHashMap map) { - final ConcurrentSoftHashMap copy = new ConcurrentSoftHashMap(); - for (final Map.Entry entry : map.entrySet()) { - copy.put(entry.getKey(), entry.getValue()); - } - return copy; - } -} \ No newline at end of file diff --git a/xml/dom-impl/src/com/intellij/util/xml/ModelMergerImpl.java b/xml/dom-impl/src/com/intellij/util/xml/ModelMergerImpl.java index 0710b07d2fe9..fb2fe38605e9 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/ModelMergerImpl.java +++ b/xml/dom-impl/src/com/intellij/util/xml/ModelMergerImpl.java @@ -5,8 +5,6 @@ import com.intellij.util.ReflectionCache; import com.intellij.util.ReflectionUtil; import com.intellij.util.SmartList; import com.intellij.util.containers.ConcurrentFactoryMap; -import com.intellij.util.containers.ConcurrentSoftArrayHashMap; -import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.FactoryMap; import com.intellij.util.xml.impl.DomInvocationHandler; import com.intellij.util.xml.impl.DomManagerImpl; @@ -27,12 +25,6 @@ import java.util.*; * @author peter */ public class ModelMergerImpl implements ModelMerger { - // [greg] the key should actually be the MergingStrategy class, but this will break the API - private final ConcurrentFactoryMap> myMergedMap = new ConcurrentFactoryMap>() { - protected ConcurrentSoftArrayHashMap create(final Class key) { - return new ConcurrentSoftArrayHashMap(ContainerUtil.identityStrategy()); - } - }; private final List> myInvocationStrategies = new ArrayList>(); private final List myMergingStrategies = new ArrayList(); private final List myMergingStrategyClasses = new ArrayList(); @@ -195,10 +187,6 @@ public class ModelMergerImpl implements ModelMerger { } public T mergeModels(final Class aClass, final T... implementations) { - /*final Object o = myMergedMap.get(aClass).get(implementations); - if (o != null) { - return (T)o; - }*/ if (implementations.length == 1) return implementations[0]; final MergingInvocationHandler handler = new MergingInvocationHandler(aClass, Arrays.asList(implementations)); return _mergeModels(aClass, handler, implementations); @@ -214,7 +202,6 @@ public class ModelMergerImpl implements ModelMerger { commonClasses.add(MERGED_OBJECT_CLASS); commonClasses.add(aClass); final T t = AdvancedProxy.createProxy(handler, null, commonClasses.toArray(new Class[commonClasses.size()])); - //myMergedMap.get(aClass).put(implementations, t); return t; }