You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2015/03/25 11:23:46 UTC
[3/6] camel git commit: CAMEL-5398: Optimize String.replaceAll with
helper method which is faster as not using regexp.
CAMEL-5398: Optimize String.replaceAll with helper method which is faster as not using regexp.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/161ee7ed
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/161ee7ed
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/161ee7ed
Branch: refs/heads/master
Commit: 161ee7ed0c2ec1456e4b695d75e2bafbe778f45d
Parents: e218337
Author: Claus Ibsen <da...@apache.org>
Authored: Wed Mar 25 10:33:38 2015 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Wed Mar 25 11:25:10 2015 +0100
----------------------------------------------------------------------
.../main/java/org/apache/camel/util/EndpointHelper.java | 2 +-
.../java/org/apache/camel/util/IntrospectionSupport.java | 3 ++-
.../src/main/java/org/apache/camel/util/StringHelper.java | 10 +++++++---
.../src/main/java/org/apache/camel/util/URISupport.java | 3 ++-
4 files changed, 12 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/161ee7ed/camel-core/src/main/java/org/apache/camel/util/EndpointHelper.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/util/EndpointHelper.java b/camel-core/src/main/java/org/apache/camel/util/EndpointHelper.java
index 18181b3..0fd0dac 100644
--- a/camel-core/src/main/java/org/apache/camel/util/EndpointHelper.java
+++ b/camel-core/src/main/java/org/apache/camel/util/EndpointHelper.java
@@ -318,7 +318,7 @@ public final class EndpointHelper {
* <code>mandatory</code> is <code>true</code>.
*/
public static <T> T resolveReferenceParameter(CamelContext context, String value, Class<T> type, boolean mandatory) {
- String valueNoHash = value.replaceAll("#", "");
+ String valueNoHash = StringHelper.replaceAll(value, "#", "");
if (mandatory) {
return CamelContextHelper.mandatoryLookup(context, valueNoHash, type);
} else {
http://git-wip-us.apache.org/repos/asf/camel/blob/161ee7ed/camel-core/src/main/java/org/apache/camel/util/IntrospectionSupport.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/util/IntrospectionSupport.java b/camel-core/src/main/java/org/apache/camel/util/IntrospectionSupport.java
index 98caa8e..d04c310 100755
--- a/camel-core/src/main/java/org/apache/camel/util/IntrospectionSupport.java
+++ b/camel-core/src/main/java/org/apache/camel/util/IntrospectionSupport.java
@@ -497,7 +497,8 @@ public final class IntrospectionSupport {
Object ref = value;
// try and lookup the reference based on the method
if (context != null && refName != null && ref == null) {
- ref = CamelContextHelper.lookup(context, refName.replaceAll("#", ""));
+ String s = StringHelper.replaceAll(refName, "#", "");
+ ref = CamelContextHelper.lookup(context, s);
if (ref == null) {
// try the next method if nothing was found
continue;
http://git-wip-us.apache.org/repos/asf/camel/blob/161ee7ed/camel-core/src/main/java/org/apache/camel/util/StringHelper.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/util/StringHelper.java b/camel-core/src/main/java/org/apache/camel/util/StringHelper.java
index 6b81015..e68b8bf 100644
--- a/camel-core/src/main/java/org/apache/camel/util/StringHelper.java
+++ b/camel-core/src/main/java/org/apache/camel/util/StringHelper.java
@@ -73,8 +73,8 @@ public final class StringHelper {
return s;
}
- s = s.replaceAll("'", "");
- s = s.replaceAll("\"", "");
+ s = replaceAll(s, "'", "");
+ s = replaceAll(s, "\"", "");
return s;
}
@@ -121,7 +121,11 @@ public final class StringHelper {
return "";
}
// must replace amp first, so we dont replace < to amp later
- return text.replaceAll("&", "&").replaceAll("\"", """).replaceAll("<", "<").replaceAll(">", ">");
+ text = replaceAll(text, "&", "&");
+ text = replaceAll(text, "\"", """);
+ text = replaceAll(text, "<", "<");
+ text = replaceAll(text, ">", ">");
+ return text;
}
/**
http://git-wip-us.apache.org/repos/asf/camel/blob/161ee7ed/camel-core/src/main/java/org/apache/camel/util/URISupport.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/util/URISupport.java b/camel-core/src/main/java/org/apache/camel/util/URISupport.java
index 5962247..02d3447 100644
--- a/camel-core/src/main/java/org/apache/camel/util/URISupport.java
+++ b/camel-core/src/main/java/org/apache/camel/util/URISupport.java
@@ -258,7 +258,8 @@ public final class URISupport {
name = URLDecoder.decode(name, CHARSET);
if (!isRaw) {
// need to replace % with %25
- value = URLDecoder.decode(value.replaceAll("%", "%25"), CHARSET);
+ String s = StringHelper.replaceAll(value, "%", "%25");
+ value = URLDecoder.decode(s, CHARSET);
}
// does the key already exist?