Author: krosenvold Date: Fri Aug 23 15:28:03 2013 New Revision: 1516883 URL: http://svn.apache.org/r1516883 Log: Used compiled regexes
Modified: maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/io/MatchPattern.java maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/io/SelectorUtils.java Modified: maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/io/MatchPattern.java URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/io/MatchPattern.java?rev=1516883&r1=1516882&r2=1516883&view=diff ============================================================================== --- maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/io/MatchPattern.java (original) +++ maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/io/MatchPattern.java Fri Aug 23 15:28:03 2013 @@ -23,6 +23,7 @@ import java.io.File; import java.util.ArrayList; import java.util.List; import java.util.StringTokenizer; +import java.util.regex.Pattern; import javax.annotation.Nonnull; @@ -39,6 +40,8 @@ public class MatchPattern private final String regexPattern; + private final Pattern regexPatternRegex; + private final String separator; private final String[] tokenized; @@ -48,6 +51,7 @@ public class MatchPattern regexPattern = SelectorUtils.isRegexPrefixedPattern( source ) ? source.substring( SelectorUtils.REGEX_HANDLER_PREFIX.length(), source.length() - SelectorUtils.PATTERN_HANDLER_SUFFIX.length() ) : null; + regexPatternRegex = regexPattern != null ? Pattern.compile( regexPattern ) : null; this.source = SelectorUtils.isAntPrefixedPattern( source ) ? source.substring( SelectorUtils.ANT_HANDLER_PREFIX.length(), source.length() @@ -62,7 +66,7 @@ public class MatchPattern { if ( regexPattern != null ) { - return str.matches( regexPattern ); + return regexPatternRegex.matcher( str).matches(); } else { @@ -74,7 +78,7 @@ public class MatchPattern { if ( regexPattern != null ) { - return str.matches( regexPattern ); + return regexPatternRegex.matcher( str).matches(); } else { Modified: maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/io/SelectorUtils.java URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/io/SelectorUtils.java?rev=1516883&r1=1516882&r2=1516883&view=diff ============================================================================== --- maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/io/SelectorUtils.java (original) +++ maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/io/SelectorUtils.java Fri Aug 23 15:28:03 2013 @@ -606,11 +606,18 @@ public final class SelectorUtils boolean isCaseSensitive ) { String[] strDirs = tokenizePathToString( str, separator ); + return matchAntPathPatternStart( patDirs, strDirs, isCaseSensitive ); + } + + private static boolean matchAntPathPatternStart( @Nonnull String[] patDirs, + @Nonnull String[] tokenizedFileName, + boolean isCaseSensitive ) + { int patIdxStart = 0; int patIdxEnd = patDirs.length - 1; int strIdxStart = 0; - int strIdxEnd = strDirs.length - 1; + int strIdxEnd = tokenizedFileName.length - 1; // up to first '**' while ( patIdxStart <= patIdxEnd && strIdxStart <= strIdxEnd ) @@ -620,7 +627,7 @@ public final class SelectorUtils { break; } - if ( !match( patDir, strDirs[strIdxStart], isCaseSensitive ) ) + if ( !match( patDir, tokenizedFileName[strIdxStart], isCaseSensitive ) ) { return false; }