This is an automated email from the ASF dual-hosted git repository.

orpiske pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 1ebfcb051de9f50f2abd831dc1a2aebbc9cd7536
Author: Otavio Rodolfo Piske <angusyo...@gmail.com>
AuthorDate: Tue May 23 19:30:17 2023 +0200

    (chores) camel-util: avoid unnecessary work when parsing the query
---
 .../src/main/java/org/apache/camel/util/URIScanner.java     | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git 
a/core/camel-util/src/main/java/org/apache/camel/util/URIScanner.java 
b/core/camel-util/src/main/java/org/apache/camel/util/URIScanner.java
index b9cdd125ddf..d965d4a9ed1 100644
--- a/core/camel-util/src/main/java/org/apache/camel/util/URIScanner.java
+++ b/core/camel-util/src/main/java/org/apache/camel/util/URIScanner.java
@@ -62,17 +62,10 @@ class URIScanner {
         Map<String, Object> answer = new LinkedHashMap<>();
 
         // parse the uri parameters char by char
-        int len = uri.length();
+        final int len = uri.length();
         for (int i = 0; i < len; i++) {
             // current char
-            char ch = uri.charAt(i);
-            // look ahead of the next char
-            char next;
-            if (i <= len - 2) {
-                next = uri.charAt(i + 1);
-            } else {
-                next = END;
-            }
+            final char ch = uri.charAt(i);
 
             if (keyMode) {
                 // if there is a = sign then the key ends and we are in value 
mode
@@ -93,6 +86,8 @@ class URIScanner {
                 if (isRaw) {
                     value.append(ch);
 
+                    // look ahead of the next char
+                    final char next = i <= len - 2 ? uri.charAt(i + 1) : END;
                     if (isAtEnd(ch, next)) {
                         // raw value end, so add that as a parameter, and 
reset flags
                         addParameter(answer, useRaw || isRaw);

Reply via email to