aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/objective-c/GRPCClient/private/GRPCChannel.m
diff options
context:
space:
mode:
authorGravatar Muxi Yan <mxyan@google.com>2018-10-17 18:04:42 -0700
committerGravatar Muxi Yan <mxyan@google.com>2018-10-17 18:04:42 -0700
commit34e4db810fcf08f51ee5104561426fc736308216 (patch)
tree5997dc7e2776f45e27488e28096ea72ce6f4717c /src/objective-c/GRPCClient/private/GRPCChannel.m
parentd578b4321812715de7fe615a1ae8624fd05f1c69 (diff)
Take advantage of nil messaging
Diffstat (limited to 'src/objective-c/GRPCClient/private/GRPCChannel.m')
-rw-r--r--src/objective-c/GRPCClient/private/GRPCChannel.m16
1 files changed, 5 insertions, 11 deletions
diff --git a/src/objective-c/GRPCClient/private/GRPCChannel.m b/src/objective-c/GRPCClient/private/GRPCChannel.m
index 9e7e1ea1fc..5e0b37c1b8 100644
--- a/src/objective-c/GRPCClient/private/GRPCChannel.m
+++ b/src/objective-c/GRPCClient/private/GRPCChannel.m
@@ -84,10 +84,8 @@ NSTimeInterval kChannelDestroyDelay = 30;
- (void)refChannel {
if (!_disconnected) {
_refCount++;
- if (_timer) {
- [_timer invalidate];
- _timer = nil;
- }
+ [_timer invalidate];
+ _timer = nil;
}
}
@@ -96,9 +94,7 @@ NSTimeInterval kChannelDestroyDelay = 30;
if (!_disconnected) {
_refCount--;
if (_refCount == 0) {
- if (_timer) {
- [_timer invalidate];
- }
+ [_timer invalidate];
_timer = [NSTimer scheduledTimerWithTimeInterval:self->_destroyDelay
target:self
selector:@selector(timerFire:)
@@ -111,10 +107,8 @@ NSTimeInterval kChannelDestroyDelay = 30;
// This function is protected by channel dispatch queue.
- (void)disconnect {
if (!_disconnected) {
- if (self->_timer != nil) {
- [self->_timer invalidate];
- self->_timer = nil;
- }
+ [_timer invalidate];
+ _timer = nil;
_disconnected = YES;
// Break retain loop
_destroyChannelCallback = nil;