7060642: (javadoc) improve performance on accessing inlinedTags
Reviewed-by: jjg, bpatel
--- a/langtools/src/share/classes/com/sun/tools/javadoc/ParamTagImpl.java Fri Jul 01 13:34:37 2011 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javadoc/ParamTagImpl.java Fri Jul 01 14:28:19 2011 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -44,6 +44,11 @@
private final String parameterComment;
private final boolean isTypeParameter;
+ /**
+ * Cached inline tags.
+ */
+ private Tag[] inlineTags;
+
ParamTagImpl(DocImpl holder, String name, String text) {
super(holder, name, text);
String[] sa = divideAtWhite();
@@ -71,6 +76,7 @@
/**
* Return the kind of this tag.
*/
+ @Override
public String kind() {
return "@param";
}
@@ -85,6 +91,7 @@
/**
* convert this object to a string.
*/
+ @Override
public String toString() {
return name + ":" + text;
}
@@ -97,7 +104,11 @@
* @see TagImpl#inlineTagImpls()
* @see ThrowsTagImpl#inlineTagImpls()
*/
+ @Override
public Tag[] inlineTags() {
- return Comment.getInlineTags(holder, parameterComment);
+ if (inlineTags == null) {
+ inlineTags = Comment.getInlineTags(holder, parameterComment);
+ }
+ return inlineTags;
}
}
--- a/langtools/src/share/classes/com/sun/tools/javadoc/ThrowsTagImpl.java Fri Jul 01 13:34:37 2011 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javadoc/ThrowsTagImpl.java Fri Jul 01 14:28:19 2011 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -43,6 +43,11 @@
private final String exceptionName;
private final String exceptionComment;
+ /**
+ * Cached inline tags.
+ */
+ private Tag[] inlineTags;
+
ThrowsTagImpl(DocImpl holder, String name, String text) {
super(holder, name, text);
String[] sa = divideAtWhite();
@@ -93,6 +98,7 @@
* Return the kind of this tag. Always "@throws" for instances
* of ThrowsTagImpl.
*/
+ @Override
public String kind() {
return "@throws";
}
@@ -105,7 +111,11 @@
* @see TagImpl#inlineTagImpls()
* @see ParamTagImpl#inlineTagImpls()
*/
+ @Override
public Tag[] inlineTags() {
- return Comment.getInlineTags(holder, exceptionComment());
+ if (inlineTags == null) {
+ inlineTags = Comment.getInlineTags(holder, exceptionComment());
+ }
+ return inlineTags;
}
}