Skip to content

Commit

Permalink
Merge pull request #112 from timlueg/2.3-gae
Browse files Browse the repository at this point in the history
Avoid unnecessary Pattern.compile calls in MemberSelector
  • Loading branch information
ddekany authored Aug 21, 2024
2 parents dda4faf + fb80ca9 commit 30a6e32
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.util.Collection;
import java.util.List;
import java.util.StringTokenizer;
import java.util.regex.Pattern;

import freemarker.template.utility.ClassUtil;
import freemarker.template.utility.NullArgumentException;
Expand Down Expand Up @@ -92,6 +93,7 @@ public final static class MemberSelector {
private final Method method;
private final Constructor<?> constructor;
private final Field field;
private static final Pattern patternCleanStr = Pattern.compile("\\s*([\\.,\\(\\)\\[\\]])\\s*");

/**
* Use if you want to match methods similar to the specified one, in types that are {@code instanceof} of
Expand Down Expand Up @@ -193,8 +195,7 @@ public static MemberSelector parse(String memberSelectorString, ClassLoader clas
"Malformed whitelist entry (shouldn't contain \"<\", \">\", \"...\", or \";\"): "
+ memberSelectorString);
}
String cleanedStr = memberSelectorString.trim().replaceAll("\\s*([\\.,\\(\\)\\[\\]])\\s*", "$1");

String cleanedStr = patternCleanStr.matcher(memberSelectorString.trim()).replaceAll("$1");
int postMemberNameIdx;
boolean hasArgList;
{
Expand Down

0 comments on commit 30a6e32

Please sign in to comment.