Skip to content

Commit 6d7eadd

Browse files
authored
perf: Skip registering auth delegate if it's already registered (#1715)
1 parent 701c819 commit 6d7eadd

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

Parse/Parse/Internal/User/AuthenticationProviders/Controller/PFUserAuthenticationController.m

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,19 @@ - (void)registerAuthenticationDelegate:(id<PFUserAuthenticationDelegate>)delegat
5656
PFParameterAssert(delegate, @"Authentication delegate can't be `nil`.");
5757
PFParameterAssert(authType, @"`authType` can't be `nil`.");
5858

59-
// If auth delete is already registered then unregister it gracefully
59+
// If auth delete is already registered for provider
6060
if ([self authenticationDelegateForAuthType:authType]) {
61+
62+
// If same auth delete is already registered then don't register it again
63+
if ([self authenticationDelegateForAuthType:authType] == delegate) {
64+
NSLog(@"skipping registering as same delegate already registered for authType `%@`.", authType);
65+
return;
66+
}
67+
6168
NSLog(@"unregistering existing deletegate to gracefully register new delegate for authType `%@`.", authType);
6269
[self unregisterAuthenticationDelegateForAuthType:authType];
6370
}
64-
71+
6572
dispatch_sync(_dataAccessQueue, ^{
6673
self->_authenticationDelegates[authType] = delegate;
6774
});

0 commit comments

Comments
 (0)