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,8 +341,13 @@ 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.
@ -354,8 +359,13 @@ 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.
@ -380,8 +390,13 @@ 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.

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,12 +252,22 @@ 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

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,12 +203,22 @@ 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

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,11 +334,16 @@ public class PackageDocImpl extends DocImpl implements PackageDoc {
* Get package name. * Get package name.
*/ */
public String qualifiedName() { public String qualifiedName() {
if (qualifiedName == null) {
Name fullname = sym.getQualifiedName(); Name fullname = sym.getQualifiedName();
// Some bogus tests depend on the interned "" being returned. // Some bogus tests depend on the interned "" being returned.
// See 6457276. // See 6457276.
return fullname.isEmpty() ? "" : fullname.toString(); qualifiedName = fullname.isEmpty() ? "" : fullname.toString();
} }
return qualifiedName;
}
private String qualifiedName;
/** /**
* set doc path for an unzipped directory * set doc path for an unzipped directory