Additional improvements for
authorkkolinko <kkolinko@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 12 Jan 2011 05:23:49 +0000 (05:23 +0000)
committerkkolinko <kkolinko@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 12 Jan 2011 05:23:49 +0000 (05:23 +0000)
https://issues.apache.org/bugzilla/show_bug.cgi?id=50205
Followup to r1057788
1) Simplify check for absence of value
2) Reuse Matcher instance across iterations

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1057990 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/catalina/startup/HostConfig.java

index 9d46ff5..d3eaccb 100644 (file)
@@ -36,6 +36,7 @@ import java.util.Locale;
 import java.util.Set;
 import java.util.jar.JarEntry;
 import java.util.jar.JarFile;
+import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
 import javax.management.ObjectName;
@@ -482,15 +483,20 @@ public class HostConfig
      * @return  The filtered list of application paths
      */
     protected String[] filterAppPaths(String[] unfilteredAppPaths) {
-        if (host.getDeployIgnore() == null) {
+        Pattern filter = host.getDeployIgnorePattern();
+        if (filter == null) {
             return unfilteredAppPaths;
         }
-        
-        Pattern filter = host.getDeployIgnorePattern();
 
         List<String> filteredList = new ArrayList<String>();
+        Matcher matcher = null;
         for (String appPath : unfilteredAppPaths) {
-            if (filter.matcher(appPath).matches()) {
+            if (matcher == null) {
+                matcher = filter.matcher(appPath);
+            } else {
+                matcher.reset(appPath);
+            }
+            if (matcher.matches()) {
                 if (log.isDebugEnabled()) {
                     log.debug(sm.getString("hostConfig.ignorePath", appPath));
                 }