]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Remove unnecessary getComparableKey from HashMapBinding 97/2697/1
authorjsimomaa <jani.simomaa@gmail.com>
Tue, 18 Dec 2018 13:52:49 +0000 (15:52 +0200)
committerReino Ruusu <reino.ruusu@semantum.fi>
Mon, 25 Feb 2019 11:53:55 +0000 (11:53 +0000)
This speeds up loading e.g. 60MB mapping file from 32s to 2s

gitlab #241

Needed for district.

Change-Id: I14a4f6d4998c61f88a7d7798947e70ce041a4f1f
(cherry picked from commit e5a79f44f9d6ce5f38fb61c5db0d9af0a1db35a9)

bundles/org.simantics.databoard/src/org/simantics/databoard/binding/factory/TroveBindingsProvider.java
bundles/org.simantics.databoard/src/org/simantics/databoard/binding/impl/HashMapBinding.java

index 3eb17213be03a74d8a6ac00da6dde81ea48dc7d1..e8047450e331f59a1ce5900a7cd8c4d62eb43591 100644 (file)
@@ -75,7 +75,6 @@ public class TroveBindingsProvider implements BindingProvider {
                        
                        for (int i=0; i<len; i++) {
                                Object key = keys[i];
-                               key = getComparableKey(result, key);                    
                                Object value = values[i];
                                result.put(key, value);
                        }
@@ -93,7 +92,6 @@ public class TroveBindingsProvider implements BindingProvider {
                        
                        for (int i=0; i<len; i++) {
                                Object key = keys.get(i);
-                               key = getComparableKey(result, key);
                                Object value = values.get(i);
                                result.put(key, value);
                        }
index d8c63e34d15b8b72e03b9c216dc63877a06cd8fa..97eb55ac17d63a8bf93debb6188b6288a40425da 100644 (file)
@@ -68,7 +68,6 @@ public class HashMapBinding extends MapBinding {
                
                for (int i=0; i<len; i++) {
                        Object key = keys[i];
-                       key = getComparableKey(result, key);                    
                        Object value = values[i];
                        result.put(key, value);
                }
@@ -86,7 +85,6 @@ public class HashMapBinding extends MapBinding {
                
                for (int i=0; i<len; i++) {
                        Object key = keys.get(i);
-                       key = getComparableKey(result, key);
                        Object value = values.get(i);
                        result.put(key, value);
                }
@@ -225,27 +223,11 @@ public class HashMapBinding extends MapBinding {
                }
                return values;
        }
-
-       @SuppressWarnings("unchecked")
-       protected Object getComparableKey(Object map, Object key) {
-               // if (keyIsComparable) return key;
-               
-               Map<Object, Object> m = ((Map<Object, Object>)map);
-               Binding kb = getKeyBinding();
-               for (Object k : m.keySet())
-               {
-                       if (kb.equals(k, key))
-                               return k;
-               }
-               return key;
-       }
        
        @SuppressWarnings("unchecked")
        @Override
        public void put(Object map, Object key, Object value) {
                Map<Object, Object> m = ((Map<Object, Object>)map);
-               Object ck = getComparableKey(m, key);
-               m.remove(ck);
                m.put(key, value);
        }
 
@@ -254,8 +236,6 @@ public class HashMapBinding extends MapBinding {
        public <K, V> void putAll(Object map, Map<K, V>  src) throws BindingException {
                Map<K, V>  m = ((Map<K, V> )map);
                for (Entry<K, V>  e : (Set<Entry<K, V> >) src.entrySet()) {
-                       Object ck = getComparableKey(map, e.getKey());
-                       m.remove(ck);
                        m.put(e.getKey(), e.getValue());
                }
        }