Thu, 18 Apr 2013 20:00:14 -0700
8012656: cache frequently used name strings for DocImpl classes
Reviewed-by: darcy
1.1 --- a/src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java Thu Apr 18 19:58:45 2013 -0700 1.2 +++ b/src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java Thu Apr 18 20:00:14 2013 -0700 1.3 @@ -341,9 +341,14 @@ 1.4 * </pre> 1.5 */ 1.6 public String name() { 1.7 - return getClassName(tsym, false); 1.8 + if (name == null) { 1.9 + name = getClassName(tsym, false); 1.10 + } 1.11 + return name; 1.12 } 1.13 1.14 + private String name; 1.15 + 1.16 /** 1.17 * Return the qualified class name as a String. 1.18 * <pre> 1.19 @@ -354,9 +359,14 @@ 1.20 * </pre> 1.21 */ 1.22 public String qualifiedName() { 1.23 - return getClassName(tsym, true); 1.24 + if (qualifiedName == null) { 1.25 + qualifiedName = getClassName(tsym, true); 1.26 + } 1.27 + return qualifiedName; 1.28 } 1.29 1.30 + private String qualifiedName; 1.31 + 1.32 /** 1.33 * Return unqualified name of type excluding any dimension information. 1.34 * <p> 1.35 @@ -380,9 +390,14 @@ 1.36 * Return the simple name of this type. 1.37 */ 1.38 public String simpleTypeName() { 1.39 - return tsym.name.toString(); 1.40 + if (simpleTypeName == null) { 1.41 + simpleTypeName = tsym.name.toString(); 1.42 + } 1.43 + return simpleTypeName; 1.44 } 1.45 1.46 + private String simpleTypeName; 1.47 + 1.48 /** 1.49 * Return the qualified name and any type parameters. 1.50 * Each parameter is a type variable with optional bounds.
2.1 --- a/src/share/classes/com/sun/tools/javadoc/FieldDocImpl.java Thu Apr 18 19:58:45 2013 -0700 2.2 +++ b/src/share/classes/com/sun/tools/javadoc/FieldDocImpl.java Thu Apr 18 20:00:14 2013 -0700 2.3 @@ -1,5 +1,5 @@ 2.4 /* 2.5 - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. 2.6 + * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. 2.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 2.8 * 2.9 * This code is free software; you can redistribute it and/or modify it 2.10 @@ -252,13 +252,23 @@ 2.11 } 2.12 2.13 public String name() { 2.14 - return sym.name.toString(); 2.15 + if (name == null) { 2.16 + name = sym.name.toString(); 2.17 + } 2.18 + return name; 2.19 } 2.20 2.21 + private String name; 2.22 + 2.23 public String qualifiedName() { 2.24 - return sym.enclClass().getQualifiedName() + "." + name(); 2.25 + if (qualifiedName == null) } 2.26 + qualifiedName = sym.enclClass().getQualifiedName() + "." + name(); 2.27 + } 2.28 + return qualifiedName; 2.29 } 2.30 2.31 + private String qualifiedName; 2.32 + 2.33 /** 2.34 * Return the source position of the entity, or null if 2.35 * no position is available.
3.1 --- a/src/share/classes/com/sun/tools/javadoc/MethodDocImpl.java Thu Apr 18 19:58:45 2013 -0700 3.2 +++ b/src/share/classes/com/sun/tools/javadoc/MethodDocImpl.java Thu Apr 18 20:00:14 2013 -0700 3.3 @@ -1,5 +1,5 @@ 3.4 /* 3.5 - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. 3.6 + * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. 3.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3.8 * 3.9 * This code is free software; you can redistribute it and/or modify it 3.10 @@ -203,13 +203,23 @@ 3.11 3.12 3.13 public String name() { 3.14 - return sym.name.toString(); 3.15 + if (name == null) { 3.16 + name = sym.name.toString(); 3.17 + } 3.18 + return name; 3.19 } 3.20 3.21 + private String name; 3.22 + 3.23 public String qualifiedName() { 3.24 - return sym.enclClass().getQualifiedName() + "." + sym.name; 3.25 + if (qualifiedName == null) { 3.26 + qualifiedName = sym.enclClass().getQualifiedName() + "." + sym.name; 3.27 + } 3.28 + return qualifiedName; 3.29 } 3.30 3.31 + private String qualifiedName; 3.32 + 3.33 /** 3.34 * Returns a string representation of this method. Includes the 3.35 * qualified signature, the qualified method name, and any type
4.1 --- a/src/share/classes/com/sun/tools/javadoc/PackageDocImpl.java Thu Apr 18 19:58:45 2013 -0700 4.2 +++ b/src/share/classes/com/sun/tools/javadoc/PackageDocImpl.java Thu Apr 18 20:00:14 2013 -0700 4.3 @@ -1,5 +1,5 @@ 4.4 /* 4.5 - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. 4.6 + * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. 4.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4.8 * 4.9 * This code is free software; you can redistribute it and/or modify it 4.10 @@ -334,12 +334,17 @@ 4.11 * Get package name. 4.12 */ 4.13 public String qualifiedName() { 4.14 - Name fullname = sym.getQualifiedName(); 4.15 - // Some bogus tests depend on the interned "" being returned. 4.16 - // See 6457276. 4.17 - return fullname.isEmpty() ? "" : fullname.toString(); 4.18 + if (qualifiedName == null) { 4.19 + Name fullname = sym.getQualifiedName(); 4.20 + // Some bogus tests depend on the interned "" being returned. 4.21 + // See 6457276. 4.22 + qualifiedName = fullname.isEmpty() ? "" : fullname.toString(); 4.23 + } 4.24 + return qualifiedName; 4.25 } 4.26 4.27 + private String qualifiedName; 4.28 + 4.29 /** 4.30 * set doc path for an unzipped directory 4.31 */