From 4f9533c7722fa07511a94d005227961f4a4dec23 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Thu, 18 May 2006 17:29:21 +0000 Subject: 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 --- libjava/classpath/javax/swing/tree/TreePath.java | 39 +++++++++++++++--------- 1 file changed, 25 insertions(+), 14 deletions(-) (limited to 'libjava/classpath/javax/swing/tree/TreePath.java') 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 (null permitted). * - * @returns true if obj is equal to this tree path, - * and false otherwise. + * @return true if obj is equal to this tree path, + * and false 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 (null permitted). * - * @returns true if path is a descendant of this - * path, and false otherwise + * @return true if path is a descendant of this + * path, and false 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 null. * - * @returns The parent path, or null if this path has only one - * element. + * @return The parent path, or null 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; } } -- cgit v1.1