6684401: JTree isExpanded should not call itself recursively
authoralexp
Tue, 22 Jun 2010 20:36:55 +0400
changeset 5950 4beeac5abfed
parent 5949 b290affb1a33
child 5951 92b0f4dfce18
6684401: JTree isExpanded should not call itself recursively Reviewed-by: rupashka
jdk/src/share/classes/javax/swing/JTree.java
--- a/jdk/src/share/classes/javax/swing/JTree.java	Tue Jun 22 19:38:27 2010 +0400
+++ b/jdk/src/share/classes/javax/swing/JTree.java	Tue Jun 22 20:36:55 2010 +0400
@@ -1986,20 +1986,17 @@
      *               true if all nodes in the path are expanded
      */
     public boolean isExpanded(TreePath path) {
+
         if(path == null)
             return false;
-
-        // Is this node expanded?
-        Boolean value = expandedState.get(path);
-
-        if(value == null || !value.booleanValue())
-            return false;
-
-        // It is, make sure its parent is also expanded.
-        TreePath        parentPath = path.getParentPath();
-
-        if(parentPath != null)
-            return isExpanded(parentPath);
+        Object  value;
+
+        do{
+            value = expandedState.get(path);
+            if(value == null || !((Boolean)value).booleanValue())
+                return false;
+        } while( (path=path.getParentPath())!=null );
+
         return true;
     }