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

lihan pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/9.0.x by this push:
     new 4fb73ee846 Minor optimization
4fb73ee846 is described below

commit 4fb73ee846183d224d980f31fb7967352bb149a6
Author: lihan <li...@apache.org>
AuthorDate: Wed Aug 9 16:42:11 2023 +0800

    Minor optimization
---
 java/org/apache/catalina/mapper/Mapper.java | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/java/org/apache/catalina/mapper/Mapper.java 
b/java/org/apache/catalina/mapper/Mapper.java
index cccc9d529f..70e428b45b 100644
--- a/java/org/apache/catalina/mapper/Mapper.java
+++ b/java/org/apache/catalina/mapper/Mapper.java
@@ -1325,16 +1325,18 @@ public final class Mapper {
             len = end - start;
         }
         for (int i = 0; (i < len) && (result == 0); i++) {
-            if (c[i + start] > compareTo.charAt(i)) {
+            char nameChar = c[i + start];
+            char compareToChar = compareTo.charAt(i);
+            if (nameChar > compareToChar) {
                 result = 1;
-            } else if (c[i + start] < compareTo.charAt(i)) {
+            } else if (nameChar < compareToChar) {
                 result = -1;
             }
         }
         if (result == 0) {
-            if (compareTo.length() > (end - start)) {
+            if (len > (end - start)) {
                 result = -1;
-            } else if (compareTo.length() < (end - start)) {
+            } else if (len < (end - start)) {
                 result = 1;
             }
         }
@@ -1354,16 +1356,18 @@ public final class Mapper {
             len = end - start;
         }
         for (int i = 0; (i < len) && (result == 0); i++) {
-            if (Ascii.toLower(c[i + start]) > 
Ascii.toLower(compareTo.charAt(i))) {
+            int nameLower = Ascii.toLower(c[i + start]);
+            int compareLower = Ascii.toLower(compareTo.charAt(i));
+            if (nameLower > compareLower) {
                 result = 1;
-            } else if (Ascii.toLower(c[i + start]) < 
Ascii.toLower(compareTo.charAt(i))) {
+            } else if (nameLower < compareLower) {
                 result = -1;
             }
         }
         if (result == 0) {
-            if (compareTo.length() > (end - start)) {
+            if (len > (end - start)) {
                 result = -1;
-            } else if (compareTo.length() < (end - start)) {
+            } else if (len < (end - start)) {
                 result = 1;
             }
         }


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to