8012656: cache frequently used name strings for DocImpl classes

Reviewed-by: darcy
This commit is contained in:
Jonathan Gibbons 2013-04-18 20:00:14 -07:00
parent 66dde86ad0
commit 3c7d12fc05
4 changed files with 54 additions and 14 deletions

View file

@ -341,9 +341,14 @@ public class ClassDocImpl extends ProgramElementDocImpl implements ClassDoc {
* </pre> * </pre>
*/ */
public String name() { 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. * Return the qualified class name as a String.
* <pre> * <pre>
@ -354,9 +359,14 @@ public class ClassDocImpl extends ProgramElementDocImpl implements ClassDoc {
* </pre> * </pre>
*/ */
public String qualifiedName() { 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. * Return unqualified name of type excluding any dimension information.
* <p> * <p>
@ -380,9 +390,14 @@ public class ClassDocImpl extends ProgramElementDocImpl implements ClassDoc {
* Return the simple name of this type. * Return the simple name of this type.
*/ */
public String simpleTypeName() { 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. * Return the qualified name and any type parameters.
* Each parameter is a type variable with optional bounds. * Each parameter is a type variable with optional bounds.

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -252,13 +252,23 @@ public class FieldDocImpl extends MemberDocImpl implements FieldDoc {
} }
public String name() { public String name() {
return sym.name.toString(); if (name == null) {
name = sym.name.toString();
}
return name;
} }
private String name;
public String qualifiedName() { 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 * Return the source position of the entity, or null if
* no position is available. * no position is available.

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -203,13 +203,23 @@ public class MethodDocImpl
public String name() { public String name() {
return sym.name.toString(); if (name == null) {
name = sym.name.toString();
}
return name;
} }
private String name;
public String qualifiedName() { 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 * Returns a string representation of this method. Includes the
* qualified signature, the qualified method name, and any type * qualified signature, the qualified method name, and any type

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -334,12 +334,17 @@ public class PackageDocImpl extends DocImpl implements PackageDoc {
* Get package name. * Get package name.
*/ */
public String qualifiedName() { public String qualifiedName() {
Name fullname = sym.getQualifiedName(); if (qualifiedName == null) {
// Some bogus tests depend on the interned "" being returned. Name fullname = sym.getQualifiedName();
// See 6457276. // Some bogus tests depend on the interned "" being returned.
return fullname.isEmpty() ? "" : fullname.toString(); // See 6457276.
qualifiedName = fullname.isEmpty() ? "" : fullname.toString();
}
return qualifiedName;
} }
private String qualifiedName;
/** /**
* set doc path for an unzipped directory * set doc path for an unzipped directory
*/ */