diff --git a/Source/ASConfigurationInternal.mm b/Source/ASConfigurationInternal.mm index e136d3cb9..4bcc1ffd5 100644 --- a/Source/ASConfigurationInternal.mm +++ b/Source/ASConfigurationInternal.mm @@ -80,7 +80,7 @@ - (BOOL)activateExperimentalFeature:(ASExperimentalFeatures)requested // Notify delegate if needed. if (newlyTriggered != 0) { - __unsafe_unretained id del = _config.delegate; + unowned id del = _config.delegate; dispatch_async(_delegateQueue, ^{ [del textureDidActivateExperimentalFeatures:newlyTriggered]; }); diff --git a/Source/ASRunLoopQueue.mm b/Source/ASRunLoopQueue.mm index 68b202c6b..43763f362 100644 --- a/Source/ASRunLoopQueue.mm +++ b/Source/ASRunLoopQueue.mm @@ -146,8 +146,8 @@ - (instancetype)initWithRunLoop:(CFRunLoopRef)runloop retainObjects:(BOOL)retain } // Self is guaranteed to outlive the observer. Without the high cost of a weak pointer, - // __unsafe_unretained allows us to avoid flagging the memory cycle detector. - __unsafe_unretained __typeof__(self) weakSelf = self; + // unowned(__unsafe_unretained) allows us to avoid flagging the memory cycle detector. + unowned __typeof__(self) weakSelf = self; void (^handlerBlock) (CFRunLoopObserverRef observer, CFRunLoopActivity activity) = ^(CFRunLoopObserverRef observer, CFRunLoopActivity activity) { [weakSelf processQueue]; }; @@ -230,7 +230,7 @@ - (void)processQueue * object will be added to the autorelease pool. If the queue is strong, * it will retain the object until we transfer it (retain it) in itemsToProcess. */ - __unsafe_unretained id ptr = (__bridge id)[_internalQueue pointerAtIndex:i]; + unowned id ptr = (__bridge id)[_internalQueue pointerAtIndex:i]; if (ptr != nil) { foundItemCount++; if (hasExecutionBlock) { @@ -260,7 +260,7 @@ - (void)processQueue as_activity_scope_verbose(as_activity_create("Process run loop queue batch", _rootActivity, OS_ACTIVITY_FLAG_DEFAULT)); const auto itemsEnd = itemsToProcess.cend(); for (auto iterator = itemsToProcess.begin(); iterator < itemsEnd; iterator++) { - __unsafe_unretained id value = *iterator; + unowned id value = *iterator; _queueConsumer(value, isQueueDrained && iterator == itemsEnd - 1); as_log_verbose(ASDisplayLog(), "processed %@", value); } @@ -375,8 +375,8 @@ - (instancetype)init } // Self is guaranteed to outlive the observer. Without the high cost of a weak pointer, - // __unsafe_unretained allows us to avoid flagging the memory cycle detector. - __unsafe_unretained __typeof__(self) weakSelf = self; + // unowned(__unsafe_unretained) allows us to avoid flagging the memory cycle detector. + unowned __typeof__(self) weakSelf = self; _preTransactionObserver = CFRunLoopObserverCreateWithHandler(NULL, kCFRunLoopBeforeWaiting, true, kASASCATransactionQueueOrder, ^(CFRunLoopObserverRef observer, CFRunLoopActivity activity) { while (!weakSelf->_internalQueue.empty()) { [weakSelf processQueue]; diff --git a/Source/Details/ASCollectionViewLayoutController.mm b/Source/Details/ASCollectionViewLayoutController.mm index f252237db..b31bb1277 100644 --- a/Source/Details/ASCollectionViewLayoutController.mm +++ b/Source/Details/ASCollectionViewLayoutController.mm @@ -81,7 +81,7 @@ - (void)allElementsForScrolling:(ASScrollDirection)scrollDirection rangeMode:(AS } // Avoid excessive retains and releases, as well as property calls. We know the element is kept alive by map. - __unsafe_unretained ASCollectionElement *e = [map elementForLayoutAttributes:la]; + unowned ASCollectionElement *e = [map elementForLayoutAttributes:la]; if (e != nil && intersectsDisplay) { [display addObject:e]; } diff --git a/Source/Details/ASElementMap.mm b/Source/Details/ASElementMap.mm index bac1b20fa..6dd0d64dc 100644 --- a/Source/Details/ASElementMap.mm +++ b/Source/Details/ASElementMap.mm @@ -193,7 +193,7 @@ - (id)mutableCopyWithZone:(NSZone *)zone #pragma mark - NSFastEnumeration -- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id _Nullable __unsafe_unretained [])buffer count:(NSUInteger)len +- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id _Nullable unowned [])buffer count:(NSUInteger)len { return [_elementToIndexPathMap countByEnumeratingWithState:state objects:buffer count:len]; } diff --git a/Source/Details/ASPageTable.mm b/Source/Details/ASPageTable.mm index 13baa95fd..fde810830 100644 --- a/Source/Details/ASPageTable.mm +++ b/Source/Details/ASPageTable.mm @@ -128,19 +128,19 @@ + (ASPageToLayoutAttributesTable *)pageTableWithLayoutAttributes:(id __lockToken __attribute__((cleanup(_ASLockScopeUnownedCleanup))) = nsLocking; \ + unowned id __lockToken __attribute__((cleanup(_ASLockScopeUnownedCleanup))) = nsLocking; \ [__lockToken lock]; ASDISPLAYNODE_INLINE void _ASLockScopeCleanup(id __strong * const lockPtr) { [*lockPtr unlock]; } -ASDISPLAYNODE_INLINE void _ASLockScopeUnownedCleanup(id __unsafe_unretained * const lockPtr) { +ASDISPLAYNODE_INLINE void _ASLockScopeUnownedCleanup(id unowned * const lockPtr) { [*lockPtr unlock]; } diff --git a/Source/Details/ASWeakSet.mm b/Source/Details/ASWeakSet.mm index 6530271a5..a65dbff25 100644 --- a/Source/Details/ASWeakSet.mm +++ b/Source/Details/ASWeakSet.mm @@ -71,7 +71,7 @@ - (NSUInteger)count return count; } -- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(__unsafe_unretained id _Nonnull *)buffer count:(NSUInteger)len +- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(unowned id _Nonnull *)buffer count:(NSUInteger)len { return [_hashTable countByEnumeratingWithState:state objects:buffer count:len]; } diff --git a/Source/Layout/ASLayoutElement.mm b/Source/Layout/ASLayoutElement.mm index 6944f86e1..38d50d6cb 100644 --- a/Source/Layout/ASLayoutElement.mm +++ b/Source/Layout/ASLayoutElement.mm @@ -40,7 +40,7 @@ - (instancetype)init #if AS_TLS_AVAILABLE -static _Thread_local __unsafe_unretained ASLayoutElementContext *tls_context; +static _Thread_local unowned ASLayoutElementContext *tls_context; void ASLayoutElementPushContext(ASLayoutElementContext *context) { diff --git a/Source/Layout/ASLayoutSpec.mm b/Source/Layout/ASLayoutSpec.mm index 6bbdc9959..6d0ba6222 100644 --- a/Source/Layout/ASLayoutSpec.mm +++ b/Source/Layout/ASLayoutSpec.mm @@ -127,7 +127,7 @@ - (void)setChildren:(NSArray> *)children #pragma mark - NSFastEnumeration -- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id __unsafe_unretained _Nullable [_Nonnull])buffer count:(NSUInteger)len +- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id unowned _Nullable [_Nonnull])buffer count:(NSUInteger)len { return [_childrenArray countByEnumeratingWithState:state objects:buffer count:len]; } diff --git a/Source/Private/ASDisplayNode+AsyncDisplay.mm b/Source/Private/ASDisplayNode+AsyncDisplay.mm index 5cd75b939..983f6f88c 100644 --- a/Source/Private/ASDisplayNode+AsyncDisplay.mm +++ b/Source/Private/ASDisplayNode+AsyncDisplay.mm @@ -260,7 +260,7 @@ - (asyncdisplaykit_async_transaction_operation_block_t)_displayBlockWithAsynchro Color the interval red if cancelled, green otherwise. */ #if AS_SIGNPOST_ENABLE - __unsafe_unretained id ptrSelf = (id)self; + unowned id ptrSelf = (id)self; displayBlock = ^{ ASSignpostStart(LayerDisplay, ptrSelf, "%@", ASObjectDescriptionMakeTiny(ptrSelf)); id result = displayBlock();