mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-10 16:29:55 +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;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if ASDISPLAYNODE_ASSERTIONS_ENABLED
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns ASDisplayNodeFlags for the given class/instance. instance MAY BE NIL.
|
* Returns ASDisplayNodeFlags for the given class/instance. instance MAY BE NIL.
|
||||||
*
|
*
|
||||||
@ -190,8 +192,6 @@ static ASDisplayNodeMethodOverrides GetASDisplayNodeMethodOverrides(Class c)
|
|||||||
|
|
||||||
+ (void)initialize
|
+ (void)initialize
|
||||||
{
|
{
|
||||||
[super initialize];
|
|
||||||
|
|
||||||
if (self != [ASDisplayNode class]) {
|
if (self != [ASDisplayNode class]) {
|
||||||
|
|
||||||
// Subclasses should never override these. Use unused to prevent warnings
|
// 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:@");
|
class_replaceMethod(self, @selector(_staticInitialize), staticInitialize, "v:@");
|
||||||
|
|
||||||
|
|
||||||
#if DEBUG
|
|
||||||
// Check if subnodes where modified during the creation of the layout
|
// Check if subnodes where modified during the creation of the layout
|
||||||
if (self == [ASDisplayNode class]) {
|
if (self == [ASDisplayNode class]) {
|
||||||
__block IMP originalLayoutSpecThatFitsIMP = ASReplaceMethodWithBlock(self, @selector(_locked_layoutElementThatFits:), ^(ASDisplayNode *_self, ASSizeRange sizeRange) {
|
__block IMP originalLayoutSpecThatFitsIMP = ASReplaceMethodWithBlock(self, @selector(_locked_layoutElementThatFits:), ^(ASDisplayNode *_self, ASSizeRange sizeRange) {
|
||||||
@ -243,9 +242,8 @@ static ASDisplayNodeMethodOverrides GetASDisplayNodeMethodOverrides(Class c)
|
|||||||
return layoutElement;
|
return layoutElement;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
+ (void)load
|
+ (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.
|
if (superclass == subclass) return NO; // Even if the class implements the selector, it doesn't override itself.
|
||||||
Method superclassMethod = class_getInstanceMethod(superclass, selector);
|
Method superclassMethod = class_getInstanceMethod(superclass, selector);
|
||||||
Method subclassMethod = class_getInstanceMethod(subclass, selector);
|
Method subclassMethod = class_getInstanceMethod(subclass, selector);
|
||||||
IMP superclassIMP = superclassMethod ? method_getImplementation(superclassMethod) : NULL;
|
return (superclassMethod != subclassMethod);
|
||||||
IMP subclassIMP = subclassMethod ? method_getImplementation(subclassMethod) : NULL;
|
|
||||||
return (superclassIMP != subclassIMP);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL ASSubclassOverridesClassSelector(Class superclass, Class subclass, SEL selector)
|
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.
|
if (superclass == subclass) return NO; // Even if the class implements the selector, it doesn't override itself.
|
||||||
Method superclassMethod = class_getClassMethod(superclass, selector);
|
Method superclassMethod = class_getClassMethod(superclass, selector);
|
||||||
Method subclassMethod = class_getClassMethod(subclass, selector);
|
Method subclassMethod = class_getClassMethod(subclass, selector);
|
||||||
IMP superclassIMP = superclassMethod ? method_getImplementation(superclassMethod) : NULL;
|
return (superclassMethod != subclassMethod);
|
||||||
IMP subclassIMP = subclassMethod ? method_getImplementation(subclassMethod) : NULL;
|
|
||||||
return (superclassIMP != subclassIMP);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
IMP ASReplaceMethodWithBlock(Class c, SEL origSEL, id block)
|
IMP ASReplaceMethodWithBlock(Class c, SEL origSEL, id block)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user