You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by kk...@apache.org on 2014/06/21 19:30:08 UTC

svn commit: r1604437 - /tomcat/trunk/java/org/apache/catalina/mapper/Mapper.java

Author: kkolinko
Date: Sat Jun 21 17:30:07 2014
New Revision: 1604437

URL: http://svn.apache.org/r1604437
Log:
Small improvements, no functional change.
Save contexts[pos] is a local variable.
Skip versions lookup when there is the only version available.

Modified:
    tomcat/trunk/java/org/apache/catalina/mapper/Mapper.java

Modified: tomcat/trunk/java/org/apache/catalina/mapper/Mapper.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/mapper/Mapper.java?rev=1604437&r1=1604436&r2=1604437&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/mapper/Mapper.java (original)
+++ tomcat/trunk/java/org/apache/catalina/mapper/Mapper.java Sat Jun 21 17:30:07 2014
@@ -661,9 +661,11 @@ public final class Mapper {
         int uriEnd = uri.getEnd();
         int length = -1;
         boolean found = false;
+        MappedContext context = null;
         while (pos >= 0) {
-            if (uri.startsWith(contexts[pos].name)) {
-                length = contexts[pos].name.length();
+            context = contexts[pos];
+            if (uri.startsWith(context.name)) {
+                length = context.name.length();
                 if (uri.getLength() == length) {
                     found = true;
                     break;
@@ -682,20 +684,20 @@ public final class Mapper {
         }
         uri.setEnd(uriEnd);
 
-        MappedContext context;
-        if (found) {
-            context = contexts[pos];
-        } else if (contexts[0].name.equals("")) {
-            context = contexts[0];
-        } else {
-            context = null;
+        if (!found) {
+            if (contexts[0].name.equals("")) {
+                context = contexts[0];
+            } else {
+                context = null;
+            }
         }
-
         if (context == null) {
             return;
         }
+
         mappingData.contextPath.setString(context.name);
 
+        ContextVersion contextVersion = null;
         ContextVersion[] contextVersions = context.versions;
         int versionCount = contextVersions.length;
         if (versionCount > 1) {
@@ -704,11 +706,9 @@ public final class Mapper {
                 contextObjects[i] = contextVersions[i].object;
             }
             mappingData.contexts = contextObjects;
-        }
-
-        ContextVersion contextVersion = null;
-        if (version != null) {
-            contextVersion = exactFind(contextVersions, version);
+            if (version != null) {
+                contextVersion = exactFind(contextVersions, version);
+            }
         }
         if (contextVersion == null) {
             // Return the latest version



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