mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 22:25:57 +00:00
Add experiment to skip creating UIViews altogether for constants (#881)
* Add experiment to skip creating UIViews altogether for constants * Update changelog * Do it right * Annotate function * Skip all the work entirely
This commit is contained in:
@@ -45,6 +45,7 @@
|
|||||||
- Use `NS_RETURNS_RETAINED` macro to make our methods a tiny bit faster. [Adlai Holler](https://github.com/Adlai-Holler) [#843](https://github.com/TextureGroup/Texture/pull/843/)
|
- Use `NS_RETURNS_RETAINED` macro to make our methods a tiny bit faster. [Adlai Holler](https://github.com/Adlai-Holler) [#843](https://github.com/TextureGroup/Texture/pull/843/)
|
||||||
- `ASDisplayNode, ASLayoutSpec, and ASLayoutElementStyle` now conform to `NSLocking`. They act as recursive locks. Useful locking macros have been added as `ASThread.h`. Subclasses / client code can lock these objects but should be careful as usual when dealing with locks. [Adlai Holler](https://github.com/Adlai-Holler)
|
- `ASDisplayNode, ASLayoutSpec, and ASLayoutElementStyle` now conform to `NSLocking`. They act as recursive locks. Useful locking macros have been added as `ASThread.h`. Subclasses / client code can lock these objects but should be careful as usual when dealing with locks. [Adlai Holler](https://github.com/Adlai-Holler)
|
||||||
- Introduces `ASRecursiveUnfairLock` as an experiment to improve locking performance. [Adlai Holler](https://github.com/Adlai-Holler)
|
- Introduces `ASRecursiveUnfairLock` as an experiment to improve locking performance. [Adlai Holler](https://github.com/Adlai-Holler)
|
||||||
|
- Adds an experiment to shorten init time. [Adlai Holler](https://github.com/Adlai-Holler)
|
||||||
|
|
||||||
## 2.6
|
## 2.6
|
||||||
- [Xcode 9] Updated to require Xcode 9 (to fix warnings) [Garrett Moon](https://github.com/garrettmoon)
|
- [Xcode 9] Updated to require Xcode 9 (to fix warnings) [Garrett Moon](https://github.com/garrettmoon)
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ typedef NS_OPTIONS(NSUInteger, ASExperimentalFeatures) {
|
|||||||
ASExperimentalTextNode = 1 << 1, // exp_text_node
|
ASExperimentalTextNode = 1 << 1, // exp_text_node
|
||||||
ASExperimentalInterfaceStateCoalescing = 1 << 2, // exp_interface_state_coalesce
|
ASExperimentalInterfaceStateCoalescing = 1 << 2, // exp_interface_state_coalesce
|
||||||
ASExperimentalUnfairLock = 1 << 3, // exp_unfair_lock
|
ASExperimentalUnfairLock = 1 << 3, // exp_unfair_lock
|
||||||
|
ASExperimentalLayerDefaults = 1 << 4, // exp_infer_layer_defaults
|
||||||
ASExperimentalFeatureAll = 0xFFFFFFFF
|
ASExperimentalFeatureAll = 0xFFFFFFFF
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,9 @@ NSArray<NSString *> *ASExperimentalFeaturesGetNames(ASExperimentalFeatures flags
|
|||||||
{
|
{
|
||||||
NSArray *allNames = ASCreateOnce((@[@"exp_graphics_contexts",
|
NSArray *allNames = ASCreateOnce((@[@"exp_graphics_contexts",
|
||||||
@"exp_text_node",
|
@"exp_text_node",
|
||||||
@"exp_interface_state_coalesce"]));
|
@"exp_interface_state_coalesce",
|
||||||
|
@"exp_unfair_lock",
|
||||||
|
@"exp_infer_layer_defaults"]));
|
||||||
|
|
||||||
if (flags == ASExperimentalFeatureAll) {
|
if (flags == ASExperimentalFeatureAll) {
|
||||||
return allNames;
|
return allNames;
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
#import <AsyncDisplayKit/ASConfigurationInternal.h>
|
#import <AsyncDisplayKit/ASConfigurationInternal.h>
|
||||||
#import <AsyncDisplayKit/ASRecursiveUnfairLock.h>
|
#import <AsyncDisplayKit/ASRecursiveUnfairLock.h>
|
||||||
|
|
||||||
ASDISPLAYNODE_INLINE BOOL ASDisplayNodeThreadIsMain()
|
ASDISPLAYNODE_INLINE AS_WARN_UNUSED_RESULT BOOL ASDisplayNodeThreadIsMain()
|
||||||
{
|
{
|
||||||
return 0 != pthread_main_np();
|
return 0 != pthread_main_np();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,26 +25,42 @@
|
|||||||
#import <AsyncDisplayKit/ASRunLoopQueue.h>
|
#import <AsyncDisplayKit/ASRunLoopQueue.h>
|
||||||
#import <AsyncDisplayKit/ASThread.h>
|
#import <AsyncDisplayKit/ASThread.h>
|
||||||
|
|
||||||
static BOOL defaultAllowsGroupOpacity = YES;
|
static NSNumber *allowsGroupOpacityFromUIKitOrNil;
|
||||||
static BOOL defaultAllowsEdgeAntialiasing = NO;
|
static NSNumber *allowsEdgeAntialiasingFromUIKitOrNil;
|
||||||
|
|
||||||
|
BOOL ASDefaultAllowsGroupOpacity()
|
||||||
|
{
|
||||||
|
static BOOL groupOpacity;
|
||||||
|
static dispatch_once_t onceToken;
|
||||||
|
dispatch_once(&onceToken, ^{
|
||||||
|
NSNumber *groupOpacityObj = allowsGroupOpacityFromUIKitOrNil ?: [NSBundle.mainBundle objectForInfoDictionaryKey:@"UIViewGroupOpacity"];
|
||||||
|
groupOpacity = groupOpacityObj ? groupOpacityObj.boolValue : YES;
|
||||||
|
});
|
||||||
|
return groupOpacity;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL ASDefaultAllowsEdgeAntialiasing()
|
||||||
|
{
|
||||||
|
static BOOL edgeAntialiasing;
|
||||||
|
static dispatch_once_t onceToken;
|
||||||
|
dispatch_once(&onceToken, ^{
|
||||||
|
NSNumber *antialiasingObj = allowsEdgeAntialiasingFromUIKitOrNil ?: [NSBundle.mainBundle objectForInfoDictionaryKey:@"UIViewEdgeAntialiasing"];
|
||||||
|
edgeAntialiasing = antialiasingObj ? antialiasingObj.boolValue : NO;
|
||||||
|
});
|
||||||
|
return edgeAntialiasing;
|
||||||
|
}
|
||||||
|
|
||||||
void ASInitializeFrameworkMainThread(void)
|
void ASInitializeFrameworkMainThread(void)
|
||||||
{
|
{
|
||||||
ASDisplayNodeThreadIsMain();
|
ASDisplayNodeCAssertMainThread();
|
||||||
// Ensure these values are cached on the main thread before needed in the background.
|
// Ensure these values are cached on the main thread before needed in the background.
|
||||||
CALayer *layer = [[[UIView alloc] init] layer];
|
if (ASActivateExperimentalFeature(ASExperimentalLayerDefaults)) {
|
||||||
defaultAllowsGroupOpacity = layer.allowsGroupOpacity;
|
// Nop. We will gather default values on-demand in ASDefaultAllowsGroupOpacity and ASDefaultAllowsEdgeAntialiasing
|
||||||
defaultAllowsEdgeAntialiasing = layer.allowsEdgeAntialiasing;
|
} else {
|
||||||
}
|
CALayer *layer = [[[UIView alloc] init] layer];
|
||||||
|
allowsGroupOpacityFromUIKitOrNil = @(layer.allowsGroupOpacity);
|
||||||
BOOL ASDefaultAllowsGroupOpacity(void)
|
allowsEdgeAntialiasingFromUIKitOrNil = @(layer.allowsEdgeAntialiasing);
|
||||||
{
|
}
|
||||||
return defaultAllowsGroupOpacity;
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL ASDefaultAllowsEdgeAntialiasing(void)
|
|
||||||
{
|
|
||||||
return defaultAllowsEdgeAntialiasing;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL ASSubclassOverridesSelector(Class superclass, Class subclass, SEL selector)
|
BOOL ASSubclassOverridesSelector(Class superclass, Class subclass, SEL selector)
|
||||||
|
|||||||
Reference in New Issue
Block a user