6581899: JTextField & JTextArea - Poor performance with JRE 1.5.0_08
authordcherepanov
Thu, 26 Jun 2008 14:23:25 +0400
changeset 1179 b0d106998757
parent 1178 4734cf2a22bf
child 1180 3493ec3df55d
6581899: JTextField & JTextArea - Poor performance with JRE 1.5.0_08 Summary: acquire the first|last components only when the key is a traversal key Reviewed-by: ant
jdk/src/share/classes/sun/awt/EmbeddedFrame.java
--- a/jdk/src/share/classes/sun/awt/EmbeddedFrame.java	Mon Jun 23 16:03:25 2008 +0400
+++ b/jdk/src/share/classes/sun/awt/EmbeddedFrame.java	Thu Jun 26 14:23:25 2008 +0400
@@ -257,21 +257,27 @@
         Set toTest;
         Component currentFocused = e.getComponent();
 
-        Component last = getFocusTraversalPolicy().getLastComponent(this);
         toTest = getFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS);
-        if (toTest.contains(stroke) && (currentFocused == last || last == null)) {
-            if (traverseOut(FORWARD)) {
-                e.consume();
-                return true;
+        if (toTest.contains(stroke)) {
+            // 6581899: performance improvement for SortingFocusTraversalPolicy
+            Component last = getFocusTraversalPolicy().getLastComponent(this);
+            if (currentFocused == last || last == null) {
+                if (traverseOut(FORWARD)) {
+                    e.consume();
+                    return true;
+                }
             }
         }
 
-        Component first = getFocusTraversalPolicy().getFirstComponent(this);
         toTest = getFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS);
-        if (toTest.contains(stroke) && (currentFocused == first || first == null)) {
-            if (traverseOut(BACKWARD)) {
-                e.consume();
-                return true;
+        if (toTest.contains(stroke)) {
+            // 6581899: performance improvement for SortingFocusTraversalPolicy
+            Component first = getFocusTraversalPolicy().getFirstComponent(this);
+            if (currentFocused == first || first == null) {
+                if (traverseOut(BACKWARD)) {
+                    e.consume();
+                    return true;
+                }
             }
         }
         return false;