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>
*/
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 @@ public class ClassDocImpl extends ProgramElementDocImpl implements ClassDoc {
* </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 @@ public class ClassDocImpl extends ProgramElementDocImpl implements ClassDoc {
* 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.

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.
*
* 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() {
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.

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.
*
* This code is free software; you can redistribute it and/or modify it
@ -203,13 +203,23 @@ public class MethodDocImpl
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

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.
*
* 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.
*/
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
*/