8061323: JavadocTokenizer repeatedly compiles pattern to check for deprecation
authorjlahoda
Fri, 24 Oct 2014 20:07:08 +0200
changeset 27232 85cb761ea65c
parent 27231 c1ca668b421e
child 27233 ceaad401ef69
8061323: JavadocTokenizer repeatedly compiles pattern to check for deprecation Summary: Keeping the "@deprecated" Pattern in a static field. Reviewed-by: mcimadamore
langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavadocTokenizer.java
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavadocTokenizer.java	Fri Oct 24 08:34:51 2014 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavadocTokenizer.java	Fri Oct 24 20:07:08 2014 +0200
@@ -30,6 +30,7 @@
 import com.sun.tools.javac.util.*;
 
 import java.nio.*;
+import java.util.regex.Pattern;
 
 import static com.sun.tools.javac.util.LayoutCharacters.*;
 
@@ -450,11 +451,15 @@
                 scanned = true;
                 comment_reader = null;
                 if (docComment != null &&
-                        docComment.matches("(?sm).*^\\s*@deprecated( |$).*")) {
+                        DEPRECATED_PATTERN.matcher(docComment).matches()) {
                     deprecatedFlag = true;
                 }
             }
         }
+        //where:
+            private static final Pattern DEPRECATED_PATTERN =
+                    Pattern.compile("(?sm).*^\\s*@deprecated( |$).*");
+
     }
 
     @Override