Skip to content

Commit 7845492

Browse files
committed
Removed 'mutable containers' functionality.
1 parent c79543c commit 7845492

File tree

5 files changed

+1
-143
lines changed

5 files changed

+1
-143
lines changed

Parse/Internal/Object/PFObjectPrivate.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,6 @@
228228
///--------------------------------------
229229
#pragma mark - Data helpers
230230
///--------------------------------------
231-
- (void)checkForChangesToMutableContainers;
232231
- (void)rebuildEstimatedData;
233232

234233
///--------------------------------------

Parse/Internal/PFInternalUtils.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,5 @@
6464
+ (NSArray *)arrayBySplittingArray:(NSArray *)array withMaximumComponentsPerSegment:(NSUInteger)components;
6565

6666
+ (id)_stringWithFormat:(NSString *)format arguments:(NSArray *)arguments;
67-
@end
68-
69-
@interface PFJSONCacheItem : NSObject
70-
71-
@property (nonatomic, copy, readonly) NSString *hashValue;
72-
73-
- (instancetype)initWithObject:(id)object;
74-
+ (PFJSONCacheItem *)cacheFromObject:(id)object;
7567

7668
@end

Parse/Internal/PFInternalUtils.m

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -269,32 +269,3 @@ + (id)_stringWithFormat:(NSString *)format arguments:(NSArray *)arguments {
269269
}
270270

271271
@end
272-
273-
// A PFJSONCacheItem is a pairing of a json string with its hash value.
274-
// This is used by our mutable container checking.
275-
@implementation PFJSONCacheItem
276-
277-
- (instancetype)initWithObject:(id)object {
278-
self = [super init];
279-
if (!self) return nil;
280-
281-
NSObject *encoded = [[PFPointerOrLocalIdObjectEncoder objectEncoder] encodeObject:object];
282-
NSData *jsonData = [PFJSONSerialization dataFromJSONObject:encoded];
283-
_hashValue = PFMD5HashFromData(jsonData);
284-
285-
return self;
286-
}
287-
288-
- (BOOL)isEqual:(id)otherCache {
289-
if (![otherCache isKindOfClass:[PFJSONCacheItem class]]) {
290-
return NO;
291-
}
292-
293-
return [self.hashValue isEqualToString:[otherCache hashValue]];
294-
}
295-
296-
+ (PFJSONCacheItem *)cacheFromObject:(id)object {
297-
return [[PFJSONCacheItem alloc] initWithObject:object];
298-
}
299-
300-
@end

Parse/PFObject.m

Lines changed: 1 addition & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -79,25 +79,6 @@ static void PFObjectAssertValueIsKindOfValidClass(id object) {
7979
PFParameterAssert(NO, @"PFObject values may not have class: %@", [object class]);
8080
}
8181

82-
/*!
83-
Checks if a class is a of container kind to be used as a value for PFObject.
84-
*/
85-
static BOOL PFObjectValueIsKindOfMutableContainerClass(id object) {
86-
static NSArray *classes;
87-
static dispatch_once_t onceToken;
88-
dispatch_once(&onceToken, ^{
89-
classes = @[ [NSDictionary class], [NSArray class], [PFACL class], [PFGeoPoint class] ];
90-
});
91-
92-
for (Class class in classes) {
93-
if ([object isKindOfClass:class]) {
94-
return YES;
95-
}
96-
}
97-
98-
return NO;
99-
}
100-
10182
@interface PFObject () <PFObjectPrivateSubclass> {
10283
// A lock for accessing any of the internal state of this object.
10384
// Guards basically all of the variables below.
@@ -111,9 +92,6 @@ @interface PFObject () <PFObjectPrivateSubclass> {
11192
// TODO (grantland): Derive this off the EventuallyPins as opposed to +/- count.
11293
int _deletingEventually;
11394

114-
// A dictionary that maps id (objects) => PFJSONCache
115-
NSMutableDictionary *hashedObjectsCache;
116-
11795
NSString *localId;
11896

11997
// This queue is used to guarantee the order of *Eventually commands
@@ -656,7 +634,6 @@ - (BFTask *)_saveChildrenInBackgroundWithCurrentUser:(PFUser *)currentUser sessi
656634

657635
- (BOOL)isDirty:(BOOL)considerChildren {
658636
@synchronized (lock) {
659-
[self checkForChangesToMutableContainers];
660637
if (self._state.deleted || dirty || [self _hasChanges]) {
661638
return YES;
662639
}
@@ -683,7 +660,6 @@ - (BOOL)_areChildrenDirty:(NSMutableSet *)seenObjects {
683660
[seenObjects addObject:self];
684661

685662
@synchronized(lock) {
686-
[self checkpointAllMutableContainers];
687663
if (self._state.deleted || dirty || [self _hasChanges]) {
688664
return YES;
689665
}
@@ -702,62 +678,6 @@ - (BOOL)_areChildrenDirty:(NSMutableSet *)seenObjects {
702678
}
703679
}
704680

705-
///--------------------------------------
706-
#pragma mark - Mutable container management
707-
///--------------------------------------
708-
709-
- (void)checkpointAllMutableContainers {
710-
@synchronized (lock) {
711-
[_estimatedData enumerateKeysAndObjectsUsingBlock:^(NSString *key, id obj, BOOL *stop) {
712-
[self checkpointMutableContainer:obj];
713-
}];
714-
}
715-
}
716-
717-
- (void)checkpointMutableContainer:(id)object {
718-
@synchronized (lock) {
719-
if (PFObjectValueIsKindOfMutableContainerClass(object)) {
720-
[hashedObjectsCache setObject:[PFJSONCacheItem cacheFromObject:object]
721-
forKey:[NSValue valueWithNonretainedObject:object]];
722-
}
723-
}
724-
}
725-
726-
- (void)checkForChangesToMutableContainer:(id)object forKey:(NSString *)key {
727-
@synchronized (lock) {
728-
// If this is a mutable container, we should check its contents.
729-
if (PFObjectValueIsKindOfMutableContainerClass(object)) {
730-
PFJSONCacheItem *oldCacheItem = [hashedObjectsCache objectForKey:[NSValue valueWithNonretainedObject:object]];
731-
if (!oldCacheItem) {
732-
[NSException raise:NSInternalInconsistencyException
733-
format:@"PFObject contains container item that isn't cached."];
734-
} else {
735-
PFJSONCacheItem *newCacheItem = [PFJSONCacheItem cacheFromObject:object];
736-
if (![oldCacheItem isEqual:newCacheItem]) {
737-
// A mutable container changed out from under us. Treat it as a set operation.
738-
[self setObject:object forKey:key];
739-
}
740-
}
741-
} else {
742-
[hashedObjectsCache removeObjectForKey:[NSValue valueWithNonretainedObject:object]];
743-
}
744-
}
745-
}
746-
747-
- (void)checkForChangesToMutableContainers {
748-
@synchronized (lock) {
749-
NSMutableArray *unexaminedCacheKeys = [[hashedObjectsCache allKeys] mutableCopy];
750-
NSDictionary *reachableData = _estimatedData.dictionaryRepresentation;
751-
[reachableData enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
752-
[unexaminedCacheKeys removeObject:[NSValue valueWithNonretainedObject:obj]];
753-
[self checkForChangesToMutableContainer:obj forKey:key];
754-
}];
755-
756-
// Remove unchecked cache entries.
757-
[hashedObjectsCache removeObjectsForKeys:unexaminedCacheKeys];
758-
}
759-
}
760-
761681
///--------------------------------------
762682
#pragma mark - Data Availability
763683
///--------------------------------------
@@ -959,7 +879,6 @@ + (BFTask *)_migrateObjectInBackgroundFromFile:(NSString *)fileName
959879
- (NSDictionary *)RESTDictionaryWithObjectEncoder:(PFEncoder *)objectEncoder
960880
operationSetUUIDs:(NSArray **)operationSetUUIDs {
961881
@synchronized (lock) {
962-
[self checkForChangesToMutableContainers];
963882
PFObjectState *state = self._state;
964883
return [self RESTDictionaryWithObjectEncoder:objectEncoder
965884
operationSetUUIDs:operationSetUUIDs
@@ -1098,15 +1017,11 @@ - (void)mergeFromRESTDictionary:(NSDictionary *)object withDecoder:(PFDecoder *)
10981017
if ([key isEqualToString:PFObjectACLRESTKey]) {
10991018
PFACL *acl = [PFACL ACLWithDictionary:obj];
11001019
[state setServerDataObject:acl forKey:PFObjectACLRESTKey];
1101-
[self checkpointMutableContainer:acl];
11021020
return;
11031021
}
11041022

11051023
// Should be decoded
11061024
id decodedObject = [decoder decodeObject:obj];
1107-
if (PFObjectValueIsKindOfMutableContainerClass(decodedObject)) {
1108-
[self checkpointMutableContainer:decodedObject];
1109-
}
11101025
[state setServerDataObject:decodedObject forKey:key];
11111026
}];
11121027
if (state.updatedAt == nil && state.createdAt != nil) {
@@ -1125,7 +1040,6 @@ - (void)mergeFromRESTDictionary:(NSDictionary *)object withDecoder:(PFDecoder *)
11251040
}
11261041
}
11271042
[self rebuildEstimatedData];
1128-
[self checkpointAllMutableContainers];
11291043
}
11301044
}
11311045

@@ -1225,8 +1139,6 @@ - (BFTask *)_enqueueSaveEventuallyOperationAsync:(PFOperationSet *)operationSet
12251139
- (NSMutableDictionary *)_convertToDictionaryForSaving:(PFOperationSet *)changes
12261140
withObjectEncoder:(PFEncoder *)encoder {
12271141
@synchronized (lock) {
1228-
[self checkForChangesToMutableContainers];
1229-
12301142
NSMutableDictionary *serialized = [NSMutableDictionary dictionary];
12311143
[changes enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
12321144
serialized[key] = obj;
@@ -1241,12 +1153,11 @@ - (NSMutableDictionary *)_convertToDictionaryForSaving:(PFOperationSet *)changes
12411153
*/
12421154
- (void)performOperation:(PFFieldOperation *)operation forKey:(NSString *)key {
12431155
@synchronized (lock) {
1244-
id newValue = [_estimatedData applyFieldOperation:operation forKey:key];
1156+
[_estimatedData applyFieldOperation:operation forKey:key];
12451157

12461158
PFFieldOperation *oldOperation = [[self unsavedChanges] objectForKey:key];
12471159
PFFieldOperation *newOperation = [operation mergeWithPrevious:oldOperation];
12481160
[[self unsavedChanges] setObject:newOperation forKey:key];
1249-
[self checkpointMutableContainer:newValue];
12501161
[_availableKeys addObject:key];
12511162
}
12521163
}
@@ -1312,7 +1223,6 @@ - (PFObject *)mergeFromObject:(PFObject *)other {
13121223
state.updatedAt = other.updatedAt;
13131224
state.serverData = [other._state.serverData mutableCopy];
13141225
self._state = state;
1315-
[self checkpointAllMutableContainers];
13161226

13171227
dirty = NO;
13181228

@@ -1323,13 +1233,11 @@ - (PFObject *)mergeFromObject:(PFObject *)other {
13231233

13241234
- (void)_mergeAfterFetchWithResult:(NSDictionary *)result decoder:(PFDecoder *)decoder completeData:(BOOL)completeData {
13251235
@synchronized (lock) {
1326-
[self checkForChangesToMutableContainers];
13271236
[self _mergeFromServerWithResult:result decoder:decoder completeData:completeData];
13281237
if (completeData) {
13291238
[self removeOldKeysAfterFetch:result];
13301239
}
13311240
[self rebuildEstimatedData];
1332-
[self checkpointAllMutableContainers];
13331241
}
13341242
}
13351243

@@ -1358,16 +1266,12 @@ - (void)_mergeAfterSaveWithResult:(NSDictionary *)result decoder:(PFDecoder *)de
13581266
PFOperationSet *operationsForNextSave = operationSetQueue[0];
13591267
[operationsForNextSave mergeOperationSet:operationsBeforeSave];
13601268
} else {
1361-
// Merge the data from the save and the data from the server into serverData.
1362-
[self checkForChangesToMutableContainers];
1363-
13641269
PFMutableObjectState *state = [self._state mutableCopy];
13651270
[state applyOperationSet:operationsBeforeSave];
13661271
self._state = state;
13671272

13681273
[self _mergeFromServerWithResult:result decoder:decoder completeData:NO];
13691274
[self rebuildEstimatedData];
1370-
[self checkpointAllMutableContainers];
13711275
}
13721276
}
13731277
}
@@ -1401,7 +1305,6 @@ - (void)_mergeFromServerWithResult:(NSDictionary *)result decoder:(PFDecoder *)d
14011305
} else if ([key isEqualToString:PFObjectACLRESTKey]) {
14021306
PFACL *acl = [PFACL ACLWithDictionary:obj];
14031307
[state setServerDataObject:acl forKey:key];
1404-
[self checkpointMutableContainer:acl];
14051308
} else {
14061309
[state setServerDataObject:[decoder decodeObject:obj] forKey:key];
14071310
}
@@ -1691,7 +1594,6 @@ - (instancetype)init {
16911594
_estimatedData = [PFObjectEstimatedData estimatedDataFromServerData:_pfinternal_state.serverData
16921595
operationSetQueue:operationSetQueue];
16931596
_availableKeys = [NSMutableSet set];
1694-
hashedObjectsCache = [[NSMutableDictionary alloc] init];
16951597
self.taskQueue = [[PFTaskQueue alloc] init];
16961598
_eventuallyTaskQueue = [[PFTaskQueue alloc] init];
16971599

@@ -2059,7 +1961,6 @@ - (BOOL)isDirty {
20591961

20601962
- (BOOL)isDirtyForKey:(NSString *)key {
20611963
@synchronized (lock) {
2062-
[self checkForChangesToMutableContainer:_estimatedData[key] forKey:key];
20631964
return !![[self unsavedChanges] objectForKey:key];
20641965
}
20651966
}
@@ -2304,7 +2205,6 @@ - (void)revert {
23042205
[_availableKeys intersectSet:persistentKeys];
23052206

23062207
[self rebuildEstimatedData];
2307-
[self checkpointAllMutableContainers];
23082208
}
23092209
}
23102210
}
@@ -2315,7 +2215,6 @@ - (void)revertObjectForKey:(NSString *)key {
23152215
[[self unsavedChanges] removeObjectForKey:key];
23162216
[self rebuildEstimatedData];
23172217
[_availableKeys removeObject:key];
2318-
[self checkpointAllMutableContainers];
23192218
}
23202219
}
23212220
}

Parse/PFUser.m

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -499,14 +499,11 @@ - (BFTask *)signUpAsync:(BFTask *)toAwait {
499499

500500
PFConsistencyAssert(!isCurrentUser, @"Attempt to merge currentUser with itself.");
501501

502-
[self checkForChangesToMutableContainers];
503502
@synchronized ([currentUser lock]) {
504503
NSString *oldUsername = [currentUser.username copy];
505504
NSString *oldPassword = [currentUser.password copy];
506505
NSArray *oldAnonymousData = currentUser.authData[PFAnonymousUserAuthenticationType];
507506

508-
[currentUser checkForChangesToMutableContainers];
509-
510507
// Move the changes to this object over to the currentUser object.
511508
PFOperationSet *selfOperations = operationSetQueue[0];
512509
[operationSetQueue removeAllObjects];

0 commit comments

Comments
 (0)