changeset 1705:95d29b99e5b3

8012656: cache frequently used name strings for DocImpl classes Reviewed-by: darcy
author jjg
date Thu, 18 Apr 2013 20:00:14 -0700
parents 891b88acf47a
children a3655c24e232
files src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java src/share/classes/com/sun/tools/javadoc/FieldDocImpl.java src/share/classes/com/sun/tools/javadoc/MethodDocImpl.java src/share/classes/com/sun/tools/javadoc/PackageDocImpl.java
diffstat 4 files changed, 54 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java	Thu Apr 18 19:58:45 2013 -0700
+++ b/src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java	Thu Apr 18 20:00:14 2013 -0700
@@ -341,9 +341,14 @@
      * </pre>
      */
     public String name() {
-        return getClassName(tsym, false);
+        if (name == null) {
+            name = getClassName(tsym, false);
+        }
+        return name;
     }
 
+    private String name;
+
     /**
      * Return the qualified class name as a String.
      * <pre>
@@ -354,9 +359,14 @@
      * </pre>
      */
     public String qualifiedName() {
-        return getClassName(tsym, true);
+        if (qualifiedName == null) {
+            qualifiedName = getClassName(tsym, true);
+        }
+        return qualifiedName;
     }
 
+    private String qualifiedName;
+
     /**
      * Return unqualified name of type excluding any dimension information.
      * <p>
@@ -380,9 +390,14 @@
      * Return the simple name of this type.
      */
     public String simpleTypeName() {
-        return tsym.name.toString();
+        if (simpleTypeName == null) {
+            simpleTypeName = tsym.name.toString();
+        }
+        return simpleTypeName;
     }
 
+    private String simpleTypeName;
+
     /**
      * Return the qualified name and any type parameters.
      * Each parameter is a type variable with optional bounds.
--- a/src/share/classes/com/sun/tools/javadoc/FieldDocImpl.java	Thu Apr 18 19:58:45 2013 -0700
+++ b/src/share/classes/com/sun/tools/javadoc/FieldDocImpl.java	Thu Apr 18 20:00:14 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2013, 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
@@ -252,13 +252,23 @@
     }
 
     public String name() {
-        return sym.name.toString();
+        if (name == null) {
+            name = sym.name.toString();
+        }
+        return name;
     }
 
+    private String name;
+
     public String qualifiedName() {
-        return sym.enclClass().getQualifiedName() + "." + name();
+        if (qualifiedName == null) }
+            qualifiedName = sym.enclClass().getQualifiedName() + "." + name();
+        }
+        return qualifiedName;
     }
 
+    private String qualifiedName;
+
     /**
      * Return the source position of the entity, or null if
      * no position is available.
--- a/src/share/classes/com/sun/tools/javadoc/MethodDocImpl.java	Thu Apr 18 19:58:45 2013 -0700
+++ b/src/share/classes/com/sun/tools/javadoc/MethodDocImpl.java	Thu Apr 18 20:00:14 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2013, 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
@@ -203,13 +203,23 @@
 
 
     public String name() {
-        return sym.name.toString();
+        if (name == null) {
+            name = sym.name.toString();
+        }
+        return name;
     }
 
+    private String name;
+
     public String qualifiedName() {
-        return sym.enclClass().getQualifiedName() + "." + sym.name;
+        if (qualifiedName == null) {
+            qualifiedName =  sym.enclClass().getQualifiedName() + "." + sym.name;
+        }
+        return qualifiedName;
     }
 
+    private String qualifiedName;
+
     /**
      * Returns a string representation of this method.  Includes the
      * qualified signature, the qualified method name, and any type
--- a/src/share/classes/com/sun/tools/javadoc/PackageDocImpl.java	Thu Apr 18 19:58:45 2013 -0700
+++ b/src/share/classes/com/sun/tools/javadoc/PackageDocImpl.java	Thu Apr 18 20:00:14 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2013, 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
@@ -334,12 +334,17 @@
      * Get package name.
      */
     public String qualifiedName() {
-        Name fullname = sym.getQualifiedName();
-        // Some bogus tests depend on the interned "" being returned.
-        // See 6457276.
-        return fullname.isEmpty() ? "" : fullname.toString();
+        if (qualifiedName == null) {
+            Name fullname = sym.getQualifiedName();
+            // Some bogus tests depend on the interned "" being returned.
+            // See 6457276.
+            qualifiedName = fullname.isEmpty() ? "" : fullname.toString();
+        }
+        return qualifiedName;
     }
 
+    private String qualifiedName;
+
     /**
      * set doc path for an unzipped directory
      */