camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject [1/2] camel git commit: CAMEL-8280 Fixed the issue that CaseInsensitiveMap putAll takes lots of time
Date Mon, 26 Jan 2015 11:51:51 GMT
Repository: camel
Updated Branches:
  refs/heads/camel-2.13.x 6968de102 -> ad87828b4
  refs/heads/camel-2.14.x 9db8556ac -> e7638cd03


CAMEL-8280 Fixed the issue that CaseInsensitiveMap putAll takes lots of time


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/e7638cd0
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/e7638cd0
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/e7638cd0

Branch: refs/heads/camel-2.14.x
Commit: e7638cd03d66133c3b788e6dd6404ea789064ba4
Parents: 9db8556
Author: Willem Jiang <willem.jiang@gmail.com>
Authored: Mon Jan 26 19:50:52 2015 +0800
Committer: Willem Jiang <willem.jiang@gmail.com>
Committed: Mon Jan 26 19:50:52 2015 +0800

----------------------------------------------------------------------
 .../apache/camel/util/CaseInsensitiveMap.java   | 33 +++++++++++++++-----
 1 file changed, 25 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/e7638cd0/camel-core/src/main/java/org/apache/camel/util/CaseInsensitiveMap.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/util/CaseInsensitiveMap.java b/camel-core/src/main/java/org/apache/camel/util/CaseInsensitiveMap.java
index b4852d7..bafc799 100644
--- a/camel-core/src/main/java/org/apache/camel/util/CaseInsensitiveMap.java
+++ b/camel-core/src/main/java/org/apache/camel/util/CaseInsensitiveMap.java
@@ -85,17 +85,34 @@ public class CaseInsensitiveMap extends HashMap<String, Object>
{
     @Override
     public synchronized void putAll(Map<? extends String, ?> map) {
         entrySetView = null;
-        if (map != null && !map.isEmpty()) {
-            for (Map.Entry<? extends String, ?> entry : map.entrySet()) {
-                String key = entry.getKey();
-                Object value = entry.getValue();
-                String s = assembleKey(key);
-                originalKeys.put(s, key);
-                super.put(s, value);
+        if (map instanceof CaseInsensitiveMap) {
+            CaseInsensitiveMap cmap = (CaseInsensitiveMap)map;
+            originalKeys.putAll(cmap.getOriginalKeys());
+            // Calling the super.putAll() is much slower in JDK 1.7
+            for (Map.Entry<String, Object> entry : cmap.superEntrySet()) {
+                super.put(entry.getKey(), entry.getValue());
+            }
+        } else {
+            if (map != null && !map.isEmpty()) {
+                for (Map.Entry<? extends String, ?> entry : map.entrySet()) {
+                    String key = entry.getKey();
+                    Object value = entry.getValue();
+                    String s = assembleKey(key);
+                    originalKeys.put(s, key);
+                    super.put(s, value);
+                }
             }
         }
     }
-
+    
+    protected synchronized Map<String, String> getOriginalKeys() {
+        return originalKeys;
+    }
+    
+    protected synchronized Set<Map.Entry<String, Object>> superEntrySet() {
+        return super.entrySet();
+    }
+ 
     @Override
     public synchronized Object remove(Object key) {
         if (key == null) {


Mime
View raw message