Skip to content

Commit

Permalink
Merge pull request #19 from davydotcom/patch-1
Browse files Browse the repository at this point in the history
Regex patterns are heavy to iteratively compile.
  • Loading branch information
lhotari authored May 8, 2018
2 parents eb29930 + 62c12ab commit 4110d67
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;

/**
* NOTE: Based on work done by on the GSP standalone project (https://gsp.dev.java.net/)
Expand All @@ -44,6 +45,7 @@ class GroovyPageScanner implements Tokens {
private int lastLineNumberIndex = -1;
private String pageName = "Unknown";
private int maxHtmlLength = DEFAULT_MAX_HTML_LENGTH;
private Pattern isTagNameSpacePattern = Pattern.compile("^\\p{Alpha}\\w*$");

GroovyPageScanner(String text) {
Strip strip = new Strip(text);
Expand Down Expand Up @@ -247,7 +249,7 @@ private boolean isClosingTag(char c1) {
}

private boolean isTagDefinition(String tagNameSpace) {
return tagNameSpace != null && tagNameSpace.matches("^\\p{Alpha}\\w*$");
return tagNameSpace != null && isTagNameSpacePattern.matcher(tagNameSpace).matches();
}

private String getTagNamespace(int fromIndex) {
Expand Down

0 comments on commit 4110d67

Please sign in to comment.