From 43c4cf652e2d0b715aa2b3ef2b3c741ea866fd45 Mon Sep 17 00:00:00 2001 From: Sean McBride Date: Fri, 18 Oct 2024 16:25:47 -0400 Subject: [PATCH] Don't implement keyPathsForValuesAffectingValueForKey if it will do nothing but call super If there are no `noninheritedAttributes` then the `for` loop will do nothing, and the whole method does nothing but call super really. So where that's the case, just don't implement the method at all. There are other cases where the `for` loop could end up doing nothing, this doesn't eliminate all such cases, just this one. --- templates/machine.m.motemplate | 2 ++ 1 file changed, 2 insertions(+) diff --git a/templates/machine.m.motemplate b/templates/machine.m.motemplate index 70129f2c..41c9eaca 100644 --- a/templates/machine.m.motemplate +++ b/templates/machine.m.motemplate @@ -26,6 +26,7 @@ return (<$managedObjectClassName$>ID*)[super objectID]; } +<$if noninheritedAttributes.@count > 0$> + (NSSet*)keyPathsForValuesAffectingValueForKey:(NSString*)key { NSSet *keyPaths = [super keyPathsForValuesAffectingValueForKey:key]; <$foreach Attribute noninheritedAttributes do$><$if Attribute.hasDefinedAttributeType$><$if Attribute.hasScalarAttributeType && (Attribute.optional || !TemplateVar.scalarsWhenNonOptional)$> @@ -37,6 +38,7 @@ return keyPaths; } +<$endif$> <$foreach Attribute noninheritedAttributes do$> <$if Attribute.hasDefinedAttributeType$>