groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cchamp...@apache.org
Subject [08/10] groovy git commit: Precompile some regular expressions
Date Wed, 23 May 2018 19:28:16 GMT
Precompile some regular expressions


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/45e32254
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/45e32254
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/45e32254

Branch: refs/heads/master
Commit: 45e3225485ef44385ff7aa3759c2c63932e088f2
Parents: 12d3758
Author: Cedric Champeau <cchampeau@apache.org>
Authored: Wed May 23 12:03:18 2018 +0200
Committer: Cedric Champeau <cchampeau@apache.org>
Committed: Wed May 23 12:03:18 2018 +0200

----------------------------------------------------------------------
 .../org/codehaus/groovy/tools/groovydoc/SimpleGroovyDoc.java   | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/45e32254/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/SimpleGroovyDoc.java
----------------------------------------------------------------------
diff --git a/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/SimpleGroovyDoc.java
b/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/SimpleGroovyDoc.java
index 8dd1d9c..cb39402 100644
--- a/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/SimpleGroovyDoc.java
+++ b/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/SimpleGroovyDoc.java
@@ -32,6 +32,8 @@ import java.util.regex.Pattern;
 public class SimpleGroovyDoc implements GroovyDoc, GroovyTokenTypes {
     private static final Pattern TAG2_PATTERN = Pattern.compile("(?s)([a-z]+)\\s+(.*)");
     private static final Pattern TAG3_PATTERN = Pattern.compile("(?s)([a-z]+)\\s+(\\S*)\\s+(.*)");
+    private static final Pattern RAW_COMMENT_PATTERN = Pattern.compile("\"(?s).*?\\\\*\\\\s*@\"");
+    private static final Pattern TRIMMED_COMMENT_PATTERN = Pattern.compile("(?m)^\\s*\\*\\s*([^*]*)$");
     private final String name;
     private String commentText = null;
     private String rawCommentText = "";
@@ -84,9 +86,9 @@ public class SimpleGroovyDoc implements GroovyDoc, GroovyTokenTypes {
     }
 
     private void calculateTags(String rawCommentText) {
-        String trimmed = rawCommentText.replaceFirst("(?s).*?\\*\\s*@", "@");
+        String trimmed = RAW_COMMENT_PATTERN.matcher(rawCommentText).replaceFirst("@");
         if (trimmed.equals(rawCommentText)) return;
-        String cleaned = trimmed.replaceAll("(?m)^\\s*\\*\\s*([^*]*)$", "$1").trim();
+        String cleaned = TRIMMED_COMMENT_PATTERN.matcher(trimmed).replaceAll("$1").trim();
         String[] split = cleaned.split("(?m)^@");
         List<GroovyTag> result = new ArrayList<GroovyTag>();
         for (String s : split) {


Mime
View raw message