mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-10 08:20:16 +00:00
Simplify Override Checking, Only Do It When Assertions Are Enabled #trivial (#253)
* Simplify our override checking, only do it when assertions are enabled * Move those functions under the ASSERTIONS_ENABLED check
This commit is contained in:
parent
f2c85fdc32
commit
538a02f119
@ -118,6 +118,8 @@ _ASPendingState *ASDisplayNodeGetPendingState(ASDisplayNode *node)
|
||||
return result;
|
||||
}
|
||||
|
||||
#if ASDISPLAYNODE_ASSERTIONS_ENABLED
|
||||
|
||||
/**
|
||||
* Returns ASDisplayNodeFlags for the given class/instance. instance MAY BE NIL.
|
||||
*
|
||||
@ -190,8 +192,6 @@ static ASDisplayNodeMethodOverrides GetASDisplayNodeMethodOverrides(Class c)
|
||||
|
||||
+ (void)initialize
|
||||
{
|
||||
[super initialize];
|
||||
|
||||
if (self != [ASDisplayNode class]) {
|
||||
|
||||
// Subclasses should never override these. Use unused to prevent warnings
|
||||
@ -229,7 +229,6 @@ static ASDisplayNodeMethodOverrides GetASDisplayNodeMethodOverrides(Class c)
|
||||
class_replaceMethod(self, @selector(_staticInitialize), staticInitialize, "v:@");
|
||||
|
||||
|
||||
#if DEBUG
|
||||
// Check if subnodes where modified during the creation of the layout
|
||||
if (self == [ASDisplayNode class]) {
|
||||
__block IMP originalLayoutSpecThatFitsIMP = ASReplaceMethodWithBlock(self, @selector(_locked_layoutElementThatFits:), ^(ASDisplayNode *_self, ASSizeRange sizeRange) {
|
||||
@ -243,9 +242,8 @@ static ASDisplayNodeMethodOverrides GetASDisplayNodeMethodOverrides(Class c)
|
||||
return layoutElement;
|
||||
});
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
+ (void)load
|
||||
{
|
||||
|
||||
@ -30,9 +30,7 @@ BOOL ASSubclassOverridesSelector(Class superclass, Class subclass, SEL selector)
|
||||
if (superclass == subclass) return NO; // Even if the class implements the selector, it doesn't override itself.
|
||||
Method superclassMethod = class_getInstanceMethod(superclass, selector);
|
||||
Method subclassMethod = class_getInstanceMethod(subclass, selector);
|
||||
IMP superclassIMP = superclassMethod ? method_getImplementation(superclassMethod) : NULL;
|
||||
IMP subclassIMP = subclassMethod ? method_getImplementation(subclassMethod) : NULL;
|
||||
return (superclassIMP != subclassIMP);
|
||||
return (superclassMethod != subclassMethod);
|
||||
}
|
||||
|
||||
BOOL ASSubclassOverridesClassSelector(Class superclass, Class subclass, SEL selector)
|
||||
@ -40,9 +38,7 @@ BOOL ASSubclassOverridesClassSelector(Class superclass, Class subclass, SEL sele
|
||||
if (superclass == subclass) return NO; // Even if the class implements the selector, it doesn't override itself.
|
||||
Method superclassMethod = class_getClassMethod(superclass, selector);
|
||||
Method subclassMethod = class_getClassMethod(subclass, selector);
|
||||
IMP superclassIMP = superclassMethod ? method_getImplementation(superclassMethod) : NULL;
|
||||
IMP subclassIMP = subclassMethod ? method_getImplementation(subclassMethod) : NULL;
|
||||
return (superclassIMP != subclassIMP);
|
||||
return (superclassMethod != subclassMethod);
|
||||
}
|
||||
|
||||
IMP ASReplaceMethodWithBlock(Class c, SEL origSEL, id block)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user