提交 c84f5630 编写于 作者: A anthony

6887249: Get rid of double-check for isValid() idiom in validate() methods

Reviewed-by: art, dcherepanov
上级 83043586
...@@ -1583,34 +1583,31 @@ public class Container extends Component { ...@@ -1583,34 +1583,31 @@ public class Container extends Component {
* @see #validateTree * @see #validateTree
*/ */
public void validate() { public void validate() {
/* Avoid grabbing lock unless really necessary. */ boolean updateCur = false;
if (!isValid() || descendUnconditionallyWhenValidating) { synchronized (getTreeLock()) {
boolean updateCur = false; if ((!isValid() || descendUnconditionallyWhenValidating)
synchronized (getTreeLock()) { && peer != null)
if ((!isValid() || descendUnconditionallyWhenValidating) {
&& peer != null) ContainerPeer p = null;
{ if (peer instanceof ContainerPeer) {
ContainerPeer p = null; p = (ContainerPeer) peer;
if (peer instanceof ContainerPeer) { }
p = (ContainerPeer) peer; if (p != null) {
} p.beginValidate();
if (p != null) { }
p.beginValidate(); validateTree();
} if (p != null) {
validateTree(); p.endValidate();
if (p != null) { // Avoid updating cursor if this is an internal call.
p.endValidate(); // See validateUnconditionally() for details.
// Avoid updating cursor if this is an internal call. if (!descendUnconditionallyWhenValidating) {
// See validateUnconditionally() for details. updateCur = isVisible();
if (!descendUnconditionallyWhenValidating) {
updateCur = isVisible();
}
} }
} }
} }
if (updateCur) { }
updateCursorImmediately(); if (updateCur) {
} updateCursorImmediately();
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册