mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 22:25:57 +00:00
[ASDisplayNode] Optimize -setNeedsDisplay, deep mutable array copies.
These optimizations are surprisingly impactful. -setNeedsDisplay being called for every node triggered cancelAsyncDisplay, locking, and memory management overhead that is completely avoidable because Core Animation triggers first display automatically. The mutable array copy optimizations reduced this key cost by over 10x, from 52ms to 5ms on an iPad Air 2 / A8X with a real-world test case.
This commit is contained in:
@@ -18,8 +18,14 @@
|
||||
ASDISPLAYNODE_EXTERN_C_BEGIN
|
||||
|
||||
/**
|
||||
* Deep muutable copy of multidimensional array.
|
||||
* It will recursively do the multiple copy for each subarray.
|
||||
* Deep mutable copy of an array that contains arrays, which contain objects. It will go one level deep into the array to copy.
|
||||
* This method is substantially faster than the generalized version, e.g. about 10x faster, so use it whenever it fits the need.
|
||||
*/
|
||||
extern NSMutableArray<NSMutableArray *> *ASTwoDimensionalArrayDeepMutableCopy(NSArray<NSArray *> *array);
|
||||
|
||||
/**
|
||||
* Deep mutable copy of multidimensional array. This is completely generalized and supports copying mixed-depth arrays,
|
||||
* where some subarrays might contain both elements and other subarrays. It will recursively do the multiple copy for each subarray.
|
||||
*/
|
||||
extern NSObject<NSCopying> *ASMultidimensionalArrayDeepMutableCopy(NSObject<NSCopying> *obj);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user