Skip to content

Commit

Permalink
fix: Remove Unnecessary Synchronize in Dealloc (#169)
Browse files Browse the repository at this point in the history
  • Loading branch information
BrandonStalnaker authored and einsteinx2 committed Nov 30, 2022
1 parent a288ba4 commit 624891b
Showing 1 changed file with 0 additions and 20 deletions.
20 changes: 0 additions & 20 deletions mParticle-Apple-SDK/Utils/MPApplication.m
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ @interface MParticle ()
@interface MPApplication() {
NSDictionary *appInfo;
MPIUserDefaults *userDefaults;
BOOL syncUserDefaults;
}

@end
Expand All @@ -98,21 +97,12 @@ - (id)init {
}

userDefaults = [MPIUserDefaults standardUserDefaults];
syncUserDefaults = NO;

_dyld_register_func_for_add_image(addImageListCallback);

return self;
}

- (void)dealloc {
if (syncUserDefaults) {
dispatch_async(dispatch_get_main_queue(), ^{
[[MPIUserDefaults standardUserDefaults] synchronize];
});
}
}

- (NSString *)description {
return [NSString stringWithFormat:@"%@", [self dictionaryRepresentation]];
}
Expand Down Expand Up @@ -200,7 +190,6 @@ - (NSNumber *)initialLaunchTime {
if (_initialLaunchTime == nil) {
_initialLaunchTime = MPCurrentEpochInMilliseconds;
userDefaults[kMPAppInitialLaunchTimeKey] = _initialLaunchTime;
syncUserDefaults = YES;
}

return _initialLaunchTime;
Expand All @@ -222,7 +211,6 @@ - (NSNumber *)lastUseDate {

- (void)setLastUseDate:(NSNumber *)lastUseDate {
userDefaults[kMPAppLastUseDateKey] = lastUseDate;
syncUserDefaults = YES;
}

- (NSNumber *)launchCount {
Expand All @@ -232,7 +220,6 @@ - (NSNumber *)launchCount {

- (void)setLaunchCount:(NSNumber *)launchCount {
userDefaults[kMPAppLaunchCountKey] = launchCount;
syncUserDefaults = YES;
}

- (NSNumber *)launchCountSinceUpgrade {
Expand All @@ -242,7 +229,6 @@ - (NSNumber *)launchCountSinceUpgrade {

- (void)setLaunchCountSinceUpgrade:(NSNumber *)launchCountSinceUpgrade {
userDefaults[kMPAppLaunchCountSinceUpgradeKey] = launchCountSinceUpgrade;
syncUserDefaults = YES;
}

- (NSNumber *)pirated {
Expand All @@ -261,8 +247,6 @@ - (void)setStoredBuild:(NSString *)storedBuild {
} else {
[userDefaults removeMPObjectForKey:kMPAppStoredBuildKey];
}

syncUserDefaults = YES;
}

- (NSString *)storedVersion {
Expand All @@ -276,8 +260,6 @@ - (void)setStoredVersion:(NSString *)storedVersion {
} else {
[userDefaults removeMPObjectForKey:kMPAppStoredVersionKey];
}

syncUserDefaults = YES;
}

- (NSNumber *)upgradeDate {
Expand All @@ -287,7 +269,6 @@ - (NSNumber *)upgradeDate {

- (void)setUpgradeDate:(NSNumber *)upgradeDate {
userDefaults[kMPAppUpgradeDateKey] = upgradeDate;
syncUserDefaults = YES;
}

- (NSString *)version {
Expand Down Expand Up @@ -321,7 +302,6 @@ - (void)setBadgeNumber:(NSNumber * _Nullable)badgeNumber {
if (![MPStateMachine isAppExtension]) {
MPIUserDefaults *userDefaults = [MPIUserDefaults standardUserDefaults];
userDefaults[kMPAppBadgeNumberKey] = badgeNumber;
syncUserDefaults = YES;
}
}
#endif
Expand Down

0 comments on commit 624891b

Please sign in to comment.