diff options
author | Mark Wielaard <mark@gcc.gnu.org> | 2006-05-18 17:29:21 +0000 |
---|---|---|
committer | Mark Wielaard <mark@gcc.gnu.org> | 2006-05-18 17:29:21 +0000 |
commit | 4f9533c7722fa07511a94d005227961f4a4dec23 (patch) | |
tree | 9f9c470de62ee62fba1331a396450d728d2b1fad /libjava/classpath/javax/swing/tree/TreePath.java | |
parent | eaec4980e139903ae9b274d1abcf3a13946603a8 (diff) | |
download | gcc-4f9533c7722fa07511a94d005227961f4a4dec23.zip gcc-4f9533c7722fa07511a94d005227961f4a4dec23.tar.gz gcc-4f9533c7722fa07511a94d005227961f4a4dec23.tar.bz2 |
Imported GNU Classpath 0.90
Imported GNU Classpath 0.90
* scripts/makemake.tcl: LocaleData.java moved to gnu/java/locale.
* sources.am: Regenerated.
* gcj/javaprims.h: Regenerated.
* Makefile.in: Regenerated.
* gcj/Makefile.in: Regenerated.
* include/Makefile.in: Regenerated.
* testsuite/Makefile.in: Regenerated.
* gnu/java/lang/VMInstrumentationImpl.java: New override.
* gnu/java/net/local/LocalSocketImpl.java: Likewise.
* gnu/classpath/jdwp/VMMethod.java: Likewise.
* gnu/classpath/jdwp/VMVirtualMachine.java: Update to latest
interface.
* java/lang/Thread.java: Add UncaughtExceptionHandler.
* java/lang/reflect/Method.java: Implements GenericDeclaration and
isSynthetic(),
* java/lang/reflect/Field.java: Likewise.
* java/lang/reflect/Constructor.java
* java/lang/Class.java: Implements Type, GenericDeclaration,
getSimpleName() and getEnclosing*() methods.
* java/lang/Class.h: Add new public methods.
* java/lang/Math.java: Add signum(), ulp() and log10().
* java/lang/natMath.cc (log10): New function.
* java/security/VMSecureRandom.java: New override.
* java/util/logging/Logger.java: Updated to latest classpath
version.
* java/util/logging/LogManager.java: New override.
From-SVN: r113887
Diffstat (limited to 'libjava/classpath/javax/swing/tree/TreePath.java')
-rw-r--r-- | libjava/classpath/javax/swing/tree/TreePath.java | 39 |
1 files changed, 25 insertions, 14 deletions
diff --git a/libjava/classpath/javax/swing/tree/TreePath.java b/libjava/classpath/javax/swing/tree/TreePath.java index 37ec632..4671c4b 100644 --- a/libjava/classpath/javax/swing/tree/TreePath.java +++ b/libjava/classpath/javax/swing/tree/TreePath.java @@ -1,5 +1,5 @@ /* TreePath.java -- - Copyright (C) 2002, 2005 Free Software Foundation, Inc. + Copyright (C) 2002, 2005, 2006, Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -53,9 +53,15 @@ public class TreePath implements Serializable static final long serialVersionUID = 4380036194768077479L; /** - * path + * The actual patch. The {@link DefaultTreeSelectionModel#clone()} + * assumes that the TreePath is immutable, so it is marked final here. */ - private Object[] path = null; + private final Object[] path; + + /** + * The parent path (to be reused). + */ + private transient TreePath parentPath; /** @@ -153,8 +159,8 @@ public class TreePath implements Serializable * * @param object the object (<code>null</code> permitted). * - * @returns <code>true</code> if <code>obj</code> is equal to this tree path, - * and <code>false</code> otherwise. + * @return <code>true</code> if <code>obj</code> is equal to this tree path, + * and <code>false</code> otherwise. */ public boolean equals(Object object) { @@ -196,7 +202,7 @@ public class TreePath implements Serializable /** * Returns an array containing the path elements. * - * @returns An array containing the path elements. + * @return An array containing the path elements. */ public Object[] getPath() { @@ -216,7 +222,7 @@ public class TreePath implements Serializable /** * Returns the number of elements in the path. * - * @returns The number of elements in the path. + * @return The number of elements in the path. */ public int getPathCount() { @@ -248,8 +254,8 @@ public class TreePath implements Serializable * * @param path the path to check (<code>null</code> permitted). * - * @returns <code>true</code> if <code>path</code> is a descendant of this - * path, and <code>false</code> otherwise + * @return <code>true</code> if <code>path</code> is a descendant of this + * path, and <code>false</code> otherwise */ public boolean isDescendant(TreePath path) { @@ -272,7 +278,7 @@ public class TreePath implements Serializable * * @param element the element. * - * @returns A tree path. + * @return A tree path. */ public TreePath pathByAddingChild(Object element) { @@ -284,8 +290,8 @@ public class TreePath implements Serializable * as this path, except for the last one. If this path contains only one * element, the method returns <code>null</code>. * - * @returns The parent path, or <code>null</code> if this path has only one - * element. + * @return The parent path, or <code>null</code> if this path has only one + * element. */ public TreePath getParentPath() { @@ -293,7 +299,12 @@ public class TreePath implements Serializable // is what the JDK does. if (path.length <= 1) return null; - - return new TreePath(this.getPath(), path.length - 1); + + // Reuse the parent path, if possible. The parent path is requested + // during the tree repainting, so reusing generates a lot less garbage. + if (parentPath == null) + parentPath = new TreePath(this.getPath(), path.length - 1); + + return parentPath; } } |