cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject cxf git commit: [CXF-7075] Removing unnecessary map.containsKey, applying most of the proposed changes from Andy McCright
Date Wed, 05 Oct 2016 10:00:27 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.0.x-fixes 32176313e -> f57cf8758


[CXF-7075] Removing unnecessary map.containsKey, applying most of the proposed changes from
Andy McCright


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

Branch: refs/heads/3.0.x-fixes
Commit: f57cf875884446f7ad88fc8c147b35249785fa1f
Parents: 3217631
Author: Sergey Beryozkin <sberyozkin@gmail.com>
Authored: Wed Oct 5 10:57:01 2016 +0100
Committer: Sergey Beryozkin <sberyozkin@gmail.com>
Committed: Wed Oct 5 11:00:11 2016 +0100

----------------------------------------------------------------------
 .../org/apache/cxf/common/util/UrlUtils.java    |  3 ++-
 .../apache/cxf/helpers/HttpHeaderHelper.java    |  9 +++------
 .../org/apache/cxf/transport/http/Headers.java  | 20 +++++++-------------
 3 files changed, 12 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/f57cf875/core/src/main/java/org/apache/cxf/common/util/UrlUtils.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/common/util/UrlUtils.java b/core/src/main/java/org/apache/cxf/common/util/UrlUtils.java
index 8b2518e..cec4276 100644
--- a/core/src/main/java/org/apache/cxf/common/util/UrlUtils.java
+++ b/core/src/main/java/org/apache/cxf/common/util/UrlUtils.java
@@ -71,7 +71,8 @@ public final class UrlUtils {
         boolean needDecode = false;
         int escapesCount = 0;
         int i = 0;
-        while (i < value.length()) {
+        final int length = value.length();
+        while (i < length) {
             char ch = value.charAt(i++);
             if (ch == ESCAPE_CHAR) {
                 escapesCount += 1;

http://git-wip-us.apache.org/repos/asf/cxf/blob/f57cf875/core/src/main/java/org/apache/cxf/helpers/HttpHeaderHelper.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/helpers/HttpHeaderHelper.java b/core/src/main/java/org/apache/cxf/helpers/HttpHeaderHelper.java
index 049691d..112e660 100644
--- a/core/src/main/java/org/apache/cxf/helpers/HttpHeaderHelper.java
+++ b/core/src/main/java/org/apache/cxf/helpers/HttpHeaderHelper.java
@@ -69,12 +69,9 @@ public final class HttpHeaderHelper {
         return headerMap.get(getHeaderKey(key));
     }
     
-    public static String getHeaderKey(String key) {
-        if (internalHeaders.containsKey(key)) {
-            return internalHeaders.get(key);
-        } else {
-            return key;
-        }
+    public static String getHeaderKey(final String key) {
+        String headerKey = internalHeaders.get(key);
+        return headerKey == null ? key : headerKey;
     }
     
     public static String findCharset(String contentType) {

http://git-wip-us.apache.org/repos/asf/cxf/blob/f57cf875/rt/transports/http/src/main/java/org/apache/cxf/transport/http/Headers.java
----------------------------------------------------------------------
diff --git a/rt/transports/http/src/main/java/org/apache/cxf/transport/http/Headers.java b/rt/transports/http/src/main/java/org/apache/cxf/transport/http/Headers.java
index ec642c0..4879d97 100644
--- a/rt/transports/http/src/main/java/org/apache/cxf/transport/http/Headers.java
+++ b/rt/transports/http/src/main/java/org/apache/cxf/transport/http/Headers.java
@@ -402,10 +402,8 @@ public class Headers {
         for (Enumeration<String> e = req.getHeaderNames(); e.hasMoreElements();) {
             String fname = e.nextElement();
             String mappedName = HttpHeaderHelper.getHeaderKey(fname);
-            List<String> values;
-            if (headers.containsKey(mappedName)) {
-                values = headers.get(mappedName);
-            } else {
+            List<String> values = headers.get(mappedName);
+            if (values == null) {
                 values = new ArrayList<String>();
                 headers.put(mappedName, values);
             }
@@ -522,18 +520,14 @@ public class Headers {
     }
     
     void removeContentType() {
-        if (headers.containsKey(PROTOCOL_HEADERS_CONTENT_TYPE)) {
-            headers.remove(PROTOCOL_HEADERS_CONTENT_TYPE);
-        }
+        headers.remove(PROTOCOL_HEADERS_CONTENT_TYPE);
     }
 
     public String getAuthorization() {
-        if (headers.containsKey("Authorization")) {
-            List<String> authorizationLines = headers.get("Authorization");
-            if (authorizationLines != null && !authorizationLines.isEmpty()) {
-                return authorizationLines.get(0);
-            }
-        } 
+        List<String> authorizationLines = headers.get("Authorization");
+        if (authorizationLines != null && !authorizationLines.isEmpty()) {
+            return authorizationLines.get(0);
+        }
         return null;
     }
 


Mime
View raw message