1
NSCompoundPredicate를 초기화하는 데 사용되는 배열의 하위 술어 순서가 효율성에 영향을 줍니까?NSCompoundPredicate 하위 규칙 순서
예 : 예에서는
NSString * str = [self getAStr];
NSManagedObject * mo = [self getAMo];
NSString * fmt = @"(stringAttribute ==[cd] %@) AND (relationships CONTAINS %@)";
NSString * fmt2 = @"[email protected] != 0";
NSPredicate * p1 = [NSPredicate predicateWithFormat:fmt,str,mo];//expensive predicate
NSPredicate * p2 = [NSPredicate predicateWithFormat:fmt2,nil];//less expensive predicate
NSCompoundPredicate * cp = [NSCompoundPredicate andPredicateWithSubpredicates:@[p1,p2];
[self fetchSomethingWithPredicate:cp];
위 (P1 및 P2)의 변화 순서는 어떻게 복합 술어
을 평가 하는가? 분명히 p2를 먼저 평가하는 것이 더 효율적입니다. p2가 false로 평가되면 p1이 무시 될 것이라고 가정합니다.