6887249: Get rid of double-check for isValid() idiom in validate() methods
authoranthony
Fri, 23 Oct 2009 14:52:55 +0400
changeset 4263 db2d1f69a60e
parent 4262 3aee79f8498a
child 4264 40c232605c68
6887249: Get rid of double-check for isValid() idiom in validate() methods Reviewed-by: art, dcherepanov
jdk/src/share/classes/java/awt/Container.java
--- a/jdk/src/share/classes/java/awt/Container.java	Thu Oct 22 13:27:28 2009 +0400
+++ b/jdk/src/share/classes/java/awt/Container.java	Fri Oct 23 14:52:55 2009 +0400
@@ -1583,34 +1583,31 @@
      * @see #validateTree
      */
     public void validate() {
-        /* Avoid grabbing lock unless really necessary. */
-        if (!isValid() || descendUnconditionallyWhenValidating) {
-            boolean updateCur = false;
-            synchronized (getTreeLock()) {
-                if ((!isValid() || descendUnconditionallyWhenValidating)
-                        && peer != null)
-                {
-                    ContainerPeer p = null;
-                    if (peer instanceof ContainerPeer) {
-                        p = (ContainerPeer) peer;
-                    }
-                    if (p != null) {
-                        p.beginValidate();
-                    }
-                    validateTree();
-                    if (p != null) {
-                        p.endValidate();
-                        // Avoid updating cursor if this is an internal call.
-                        // See validateUnconditionally() for details.
-                        if (!descendUnconditionallyWhenValidating) {
-                            updateCur = isVisible();
-                        }
+        boolean updateCur = false;
+        synchronized (getTreeLock()) {
+            if ((!isValid() || descendUnconditionallyWhenValidating)
+                    && peer != null)
+            {
+                ContainerPeer p = null;
+                if (peer instanceof ContainerPeer) {
+                    p = (ContainerPeer) peer;
+                }
+                if (p != null) {
+                    p.beginValidate();
+                }
+                validateTree();
+                if (p != null) {
+                    p.endValidate();
+                    // Avoid updating cursor if this is an internal call.
+                    // See validateUnconditionally() for details.
+                    if (!descendUnconditionallyWhenValidating) {
+                        updateCur = isVisible();
                     }
                 }
             }
-            if (updateCur) {
-                updateCursorImmediately();
-            }
+        }
+        if (updateCur) {
+            updateCursorImmediately();
         }
     }