You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by se...@apache.org on 2016/10/05 09:57:27 UTC
cxf git commit: [CXF-7075] Removing unnecessary map.containsKey,
applying most of the proposed changes from Andy McCright
Repository: cxf
Updated Branches:
refs/heads/master de6754310 -> 885edfc55
[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/885edfc5
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/885edfc5
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/885edfc5
Branch: refs/heads/master
Commit: 885edfc55ddf5b821008967ba02336b29b7ccea5
Parents: de67543
Author: Sergey Beryozkin <sb...@gmail.com>
Authored: Wed Oct 5 10:57:01 2016 +0100
Committer: Sergey Beryozkin <sb...@gmail.com>
Committed: Wed Oct 5 10:57:01 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/885edfc5/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 3dd0087..628c092 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
@@ -72,7 +72,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/885edfc5/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 62dec05..796e2fc 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/885edfc5/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 a94d11e..23b7975 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
@@ -417,10 +417,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);
}
@@ -537,18 +535,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;
}