Permalink
Browse files

Remove nil checks before invoking -addDisposable:

  • Loading branch information...
1 parent dd19bf7 commit e00f650676147729bfd5d17c5647adf9781acb69 @jspahrsummers jspahrsummers committed Oct 19, 2013
@@ -696,7 +696,7 @@ and cause a crash:
resubscribe();
}];
- if (disposable != nil) [compoundDisposable addDisposable:disposable];
+ [compoundDisposable addDisposable:disposable];
};
return compoundDisposable;
@@ -721,10 +721,10 @@ By contrast, this version will avoid a stack overflow:
reschedule();
}];
- if (disposable != nil) [compoundDisposable addDisposable:disposable];
+ [compoundDisposable addDisposable:disposable];
}];
- if (disposable != nil) [compoundDisposable addDisposable:disposable];
+ [compoundDisposable addDisposable:disposable];
return compoundDisposable;
}];
}
@@ -176,10 +176,10 @@ - (RACDisposable *)subscribe:(id<RACSubscriber>)subscriber {
if (self.didSubscribe != NULL) {
RACDisposable *schedulingDisposable = [RACScheduler.subscriptionScheduler schedule:^{
RACDisposable *innerDisposable = self.didSubscribe(subscriber);
- if (innerDisposable != nil) [disposable addDisposable:innerDisposable];
+ [disposable addDisposable:innerDisposable];
}];
- if (schedulingDisposable != nil) [disposable addDisposable:schedulingDisposable];
+ [disposable addDisposable:schedulingDisposable];
}
return disposable;
@@ -95,7 +95,7 @@ - (void)sendCompleted {
}
- (void)didSubscribeWithDisposable:(RACDisposable *)disposable {
- if (disposable != nil && disposable != self.disposable) {
+ if (disposable != self.disposable) {
[self.disposable addDisposable:disposable];
}
}
@@ -76,7 +76,7 @@ - (RACDisposable *)subscribe:(id<RACSubscriber>)subscriber {
}
}];
- if (schedulingDisposable != nil) [compoundDisposable addDisposable:schedulingDisposable];
+ [compoundDisposable addDisposable:schedulingDisposable];
return compoundDisposable;
}
@@ -184,7 +184,7 @@ - (void)scheduleRecursiveBlock:(RACSchedulerRecursiveBlock)recursiveBlock adding
}
}];
- if (schedulingDisposable != nil) [selfDisposable addDisposable:schedulingDisposable];
+ [selfDisposable addDisposable:schedulingDisposable];
}
}
@@ -68,7 +68,7 @@
recurse();
}];
- if (subscriptionDisposable != nil) [selfDisposable addDisposable:subscriptionDisposable];
+ [selfDisposable addDisposable:subscriptionDisposable];
};
// Subscribe once immediately, and then use recursive scheduling for any
@@ -77,7 +77,7 @@
RACScheduler *recursiveScheduler = RACScheduler.currentScheduler ?: [RACScheduler scheduler];
RACDisposable *schedulingDisposable = [recursiveScheduler scheduleRecursiveBlock:recursiveBlock];
- if (schedulingDisposable != nil) [compoundDisposable addDisposable:schedulingDisposable];
+ [compoundDisposable addDisposable:schedulingDisposable];
});
return compoundDisposable;
@@ -189,7 +189,7 @@ - (RACSignal *)throttle:(NSTimeInterval)interval valuesPassingTest:(BOOL (^)(id
[subscriber sendCompleted];
}];
- if (subscriptionDisposable != nil) [compoundDisposable addDisposable:subscriptionDisposable];
+ [compoundDisposable addDisposable:subscriptionDisposable];
return compoundDisposable;
}] setNameWithFormat:@"[%@] -throttle: %f valuesPassingTest:", self.name, (double)interval];
}
@@ -205,7 +205,7 @@ - (RACSignal *)delay:(NSTimeInterval)interval {
void (^schedule)(dispatch_block_t) = ^(dispatch_block_t block) {
RACScheduler *delayScheduler = RACScheduler.currentScheduler ?: scheduler;
RACDisposable *schedulerDisposable = [delayScheduler afterDelay:interval schedule:block];
- if (schedulerDisposable != nil) [disposable addDisposable:schedulerDisposable];
+ [disposable addDisposable:schedulerDisposable];
};
RACDisposable *subscriptionDisposable = [self subscribeNext:^(id x) {
@@ -220,7 +220,7 @@ - (RACSignal *)delay:(NSTimeInterval)interval {
});
}];
- if (subscriptionDisposable != nil) [disposable addDisposable:subscriptionDisposable];
+ [disposable addDisposable:subscriptionDisposable];
return disposable;
}] setNameWithFormat:@"[%@] -delay: %f", self.name, (double)interval];
}
@@ -422,7 +422,7 @@ - (RACSignal *)combineLatestWith:(RACSignal *)signal {
}
}];
- if (selfDisposable != nil) [disposable addDisposable:selfDisposable];
+ [disposable addDisposable:selfDisposable];
RACDisposable *otherDisposable = [signal subscribeNext:^(id x) {
@synchronized (disposable) {
@@ -438,7 +438,7 @@ - (RACSignal *)combineLatestWith:(RACSignal *)signal {
}
}];
- if (otherDisposable != nil) [disposable addDisposable:otherDisposable];
+ [disposable addDisposable:otherDisposable];
return disposable;
}] setNameWithFormat:@"[%@] -combineLatestWith: %@", self.name, signal];
@@ -528,7 +528,7 @@ - (RACSignal *)flatten:(NSUInteger)maxConcurrent {
[compoundDisposable removeDisposable:disposable];
}];
- if (disposable != nil) [compoundDisposable addDisposable:disposable];
+ [compoundDisposable addDisposable:disposable];
return NO;
};
@@ -567,7 +567,7 @@ - (RACSignal *)flatten:(NSUInteger)maxConcurrent {
}
}];
- if (disposable != nil) [compoundDisposable addDisposable:disposable];
+ [compoundDisposable addDisposable:disposable];
return compoundDisposable;
}] setNameWithFormat:@"[%@] -flatten: %lu", self.name, (unsigned long)maxConcurrent];
}
@@ -642,7 +642,7 @@ - (RACDisposable *)setKeyPath:(NSString *)keyPath onObject:(NSObject *)object ni
[disposable dispose];
}];
- if (subscriptionDisposable != nil) [disposable addDisposable:subscriptionDisposable];
+ [disposable addDisposable:subscriptionDisposable];
#if DEBUG
static void *bindingsKey = &bindingsKey;
@@ -718,7 +718,7 @@ - (RACSignal *)takeUntil:(RACSignal *)signalTrigger {
triggerCompletion();
}];
- if (triggerDisposable != nil) [disposable addDisposable:triggerDisposable];
+ [disposable addDisposable:triggerDisposable];
RACDisposable *selfDisposable = [self subscribeNext:^(id x) {
[subscriber sendNext:x];
@@ -729,7 +729,7 @@ - (RACSignal *)takeUntil:(RACSignal *)signalTrigger {
[subscriber sendCompleted];
}];
- if (selfDisposable != nil) [disposable addDisposable:selfDisposable];
+ [disposable addDisposable:selfDisposable];
return disposable;
}] setNameWithFormat:@"[%@] -takeUntil: %@", self.name, signalTrigger];
@@ -945,7 +945,7 @@ - (RACSignal *)timeout:(NSTimeInterval)interval onScheduler:(RACScheduler *)sche
[subscriber sendError:[NSError errorWithDomain:RACSignalErrorDomain code:RACSignalErrorTimedOut userInfo:nil]];
}];
- if (timeoutDisposable != nil) [disposable addDisposable:timeoutDisposable];
+ [disposable addDisposable:timeoutDisposable];
RACDisposable *subscriptionDisposable = [self subscribeNext:^(id x) {
[subscriber sendNext:x];
@@ -957,7 +957,7 @@ - (RACSignal *)timeout:(NSTimeInterval)interval onScheduler:(RACScheduler *)sche
[subscriber sendCompleted];
}];
- if (subscriptionDisposable != nil) [disposable addDisposable:subscriptionDisposable];
+ [disposable addDisposable:subscriptionDisposable];
return disposable;
}] setNameWithFormat:@"[%@] -timeout: %f", self.name, (double)interval];
}
@@ -993,10 +993,10 @@ - (RACSignal *)subscribeOn:(RACScheduler *)scheduler {
[subscriber sendCompleted];
}];
- if (subscriptionDisposable != nil) [disposable addDisposable:subscriptionDisposable];
+ [disposable addDisposable:subscriptionDisposable];
}];
- if (schedulingDisposable != nil) [disposable addDisposable:schedulingDisposable];
+ [disposable addDisposable:schedulingDisposable];
return disposable;
}] setNameWithFormat:@"[%@] -subscribeOn: %@", self.name, scheduler];
}
@@ -111,7 +111,7 @@ - (void)sendCompleted {
}
- (void)didSubscribeWithDisposable:(RACDisposable *)d {
- if (d != nil) [self.disposable addDisposable:d];
+ [self.disposable addDisposable:d];
}
@end
@@ -95,7 +95,7 @@ - (void)sendCompleted {
}
- (void)didSubscribeWithDisposable:(RACDisposable *)d {
- if (d != nil) [self.disposable addDisposable:d];
+ [self.disposable addDisposable:d];
}
@end
@@ -179,7 +179,7 @@ - (RACDisposable *)after:(NSDate *)date repeatingEvery:(NSTimeInterval)interval
// Schedule the next interval.
RACDisposable *schedulingDisposable = [self after:[date dateByAddingTimeInterval:interval] repeatingEvery:interval withLeeway:leeway schedule:block];
- if (schedulingDisposable != nil) [compoundDisposable addDisposable:schedulingDisposable];
+ [compoundDisposable addDisposable:schedulingDisposable];
block();
};
@@ -188,7 +188,7 @@ - (RACDisposable *)after:(NSDate *)date repeatingEvery:(NSTimeInterval)interval
CFBinaryHeapAddValue(self.scheduledActions, (__bridge void *)action);
thisDisposable = action.disposable;
- if (thisDisposable != nil) [compoundDisposable addDisposable:thisDisposable];
+ [compoundDisposable addDisposable:thisDisposable];
}
return compoundDisposable;

0 comments on commit e00f650

Please sign in to comment.