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:
Adlai Holler 2017-05-11 11:42:15 -07:00 committed by GitHub
parent f2c85fdc32
commit 538a02f119
2 changed files with 6 additions and 12 deletions

View File

@ -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
@ -228,8 +228,7 @@ 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
{

View File

@ -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)