Improve factoring of locking and early returns for -setInterfaceState: and -setHierarchyState:

This commit is contained in:
Scott Goodson 2015-12-06 19:30:04 -08:00
parent ea144310c8
commit 1e9c4563f3

View File

@ -1696,14 +1696,16 @@ void recursivelyEnsureDisplayForLayer(CALayer *layer)
- (void)setInterfaceState:(ASInterfaceState)newState
{
ASInterfaceState oldState;
ASInterfaceState oldState = ASInterfaceStateNone;
{
ASDN::MutexLocker l(_propertyLock);
if (_interfaceState == newState) {
return;
}
oldState = _interfaceState;
_interfaceState = newState;
}
if (newState != oldState) {
if ((newState & ASInterfaceStateMeasureLayout) != (oldState & ASInterfaceStateMeasureLayout)) {
// Trigger asynchronous measurement if it is not already cached or being calculated.
}
@ -1737,7 +1739,6 @@ void recursivelyEnsureDisplayForLayer(CALayer *layer)
}
}
}
}
- (void)enterInterfaceState:(ASInterfaceState)interfaceState
{
@ -1767,9 +1768,12 @@ void recursivelyEnsureDisplayForLayer(CALayer *layer)
- (void)setHierarchyState:(ASHierarchyState)newState
{
ASHierarchyState oldState;
ASHierarchyState oldState = ASHierarchyStateNormal;
{
ASDN::MutexLocker l(_propertyLock);
if (_hierarchyState == newState) {
return;
}
oldState = _hierarchyState;
_hierarchyState = newState;
}