Skip to content

Commit d26aafb

Browse files
committed
Removed 'mutable containers' functionality.
1 parent c6cb850 commit d26aafb

File tree

5 files changed

+1
-141
lines changed

5 files changed

+1
-141
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
@@ -66,13 +66,5 @@
6666
+ (NSArray *)arrayBySplittingArray:(NSArray *)array withMaximumComponentsPerSegment:(NSUInteger)components;
6767

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

7870
@end

Parse/Internal/PFInternalUtils.m

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -274,30 +274,3 @@ + (id)_stringWithFormat:(NSString *)format arguments:(NSArray *)arguments {
274274
}
275275

276276
@end
277-
278-
// A PFJSONCacheItem is a pairing of a json string with its hash value.
279-
// This is used by our mutable container checking.
280-
@implementation PFJSONCacheItem
281-
282-
- (instancetype)initWithObject:(id)object {
283-
if (self = [super init]) {
284-
NSObject *encoded = [[PFPointerOrLocalIdObjectEncoder objectEncoder] encodeObject:object];
285-
NSData *jsonData = [PFJSONSerialization dataFromJSONObject:encoded];
286-
_hashValue = PFMD5HashFromData(jsonData);
287-
}
288-
return self;
289-
}
290-
291-
- (BOOL)isEqual:(id)otherCache {
292-
if (![otherCache isKindOfClass:[PFJSONCacheItem class]]) {
293-
return NO;
294-
}
295-
296-
return [self.hashValue isEqualToString:[otherCache hashValue]];
297-
}
298-
299-
+ (PFJSONCacheItem *)cacheFromObject:(id)object {
300-
return [[PFJSONCacheItem alloc] initWithObject:object];
301-
}
302-
303-
@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
@@ -654,7 +632,6 @@ - (BFTask *)_saveChildrenInBackgroundWithCurrentUser:(PFUser *)currentUser sessi
654632

655633
- (BOOL)isDirty:(BOOL)considerChildren {
656634
@synchronized (lock) {
657-
[self checkForChangesToMutableContainers];
658635
if (self._state.deleted || dirty || [self _hasChanges]) {
659636
return YES;
660637
}
@@ -681,7 +658,6 @@ - (BOOL)_areChildrenDirty:(NSMutableSet *)seenObjects {
681658
[seenObjects addObject:self];
682659

683660
@synchronized(lock) {
684-
[self checkpointAllMutableContainers];
685661
if (self._state.deleted || dirty || [self _hasChanges]) {
686662
return YES;
687663
}
@@ -700,62 +676,6 @@ - (BOOL)_areChildrenDirty:(NSMutableSet *)seenObjects {
700676
}
701677
}
702678

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

11031021
// Should be decoded
11041022
id decodedObject = [decoder decodeObject:obj];
1105-
if (PFObjectValueIsKindOfMutableContainerClass(decodedObject)) {
1106-
[self checkpointMutableContainer:decodedObject];
1107-
}
11081023
[state setServerDataObject:decodedObject forKey:key];
11091024
}];
11101025
if (state.updatedAt == nil && state.createdAt != nil) {
@@ -1123,7 +1038,6 @@ - (void)mergeFromRESTDictionary:(NSDictionary *)object withDecoder:(PFDecoder *)
11231038
}
11241039
}
11251040
[self rebuildEstimatedData];
1126-
[self checkpointAllMutableContainers];
11271041
}
11281042
}
11291043

@@ -1223,8 +1137,6 @@ - (BFTask *)_enqueueSaveEventuallyOperationAsync:(PFOperationSet *)operationSet
12231137
- (NSMutableDictionary *)_convertToDictionaryForSaving:(PFOperationSet *)changes
12241138
withObjectEncoder:(PFEncoder *)encoder {
12251139
@synchronized (lock) {
1226-
[self checkForChangesToMutableContainers];
1227-
12281140
NSMutableDictionary *serialized = [NSMutableDictionary dictionary];
12291141
[changes enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
12301142
serialized[key] = obj;
@@ -1239,12 +1151,11 @@ - (NSMutableDictionary *)_convertToDictionaryForSaving:(PFOperationSet *)changes
12391151
*/
12401152
- (void)performOperation:(PFFieldOperation *)operation forKey:(NSString *)key {
12411153
@synchronized (lock) {
1242-
id newValue = [_estimatedData applyFieldOperation:operation forKey:key];
1154+
[_estimatedData applyFieldOperation:operation forKey:key];
12431155

12441156
PFFieldOperation *oldOperation = [[self unsavedChanges] objectForKey:key];
12451157
PFFieldOperation *newOperation = [operation mergeWithPrevious:oldOperation];
12461158
[[self unsavedChanges] setObject:newOperation forKey:key];
1247-
[self checkpointMutableContainer:newValue];
12481159
[_availableKeys addObject:key];
12491160
}
12501161
}
@@ -1310,7 +1221,6 @@ - (PFObject *)mergeFromObject:(PFObject *)other {
13101221
state.updatedAt = other.updatedAt;
13111222
state.serverData = [other._state.serverData mutableCopy];
13121223
self._state = state;
1313-
[self checkpointAllMutableContainers];
13141224

13151225
dirty = NO;
13161226

@@ -1321,13 +1231,11 @@ - (PFObject *)mergeFromObject:(PFObject *)other {
13211231

13221232
- (void)_mergeAfterFetchWithResult:(NSDictionary *)result decoder:(PFDecoder *)decoder completeData:(BOOL)completeData {
13231233
@synchronized (lock) {
1324-
[self checkForChangesToMutableContainers];
13251234
[self _mergeFromServerWithResult:result decoder:decoder completeData:completeData];
13261235
if (completeData) {
13271236
[self removeOldKeysAfterFetch:result];
13281237
}
13291238
[self rebuildEstimatedData];
1330-
[self checkpointAllMutableContainers];
13311239
}
13321240
}
13331241

@@ -1356,16 +1264,12 @@ - (void)_mergeAfterSaveWithResult:(NSDictionary *)result decoder:(PFDecoder *)de
13561264
PFOperationSet *operationsForNextSave = operationSetQueue[0];
13571265
[operationsForNextSave mergeOperationSet:operationsBeforeSave];
13581266
} else {
1359-
// Merge the data from the save and the data from the server into serverData.
1360-
[self checkForChangesToMutableContainers];
1361-
13621267
PFMutableObjectState *state = [self._state mutableCopy];
13631268
[state applyOperationSet:operationsBeforeSave];
13641269
self._state = state;
13651270

13661271
[self _mergeFromServerWithResult:result decoder:decoder completeData:NO];
13671272
[self rebuildEstimatedData];
1368-
[self checkpointAllMutableContainers];
13691273
}
13701274
}
13711275
}
@@ -1399,7 +1303,6 @@ - (void)_mergeFromServerWithResult:(NSDictionary *)result decoder:(PFDecoder *)d
13991303
} else if ([key isEqualToString:PFObjectACLRESTKey]) {
14001304
PFACL *acl = [PFACL ACLWithDictionary:obj];
14011305
[state setServerDataObject:acl forKey:key];
1402-
[self checkpointMutableContainer:acl];
14031306
} else {
14041307
[state setServerDataObject:[decoder decodeObject:obj] forKey:key];
14051308
}
@@ -1689,7 +1592,6 @@ - (instancetype)init {
16891592
_estimatedData = [PFObjectEstimatedData estimatedDataFromServerData:_pfinternal_state.serverData
16901593
operationSetQueue:operationSetQueue];
16911594
_availableKeys = [NSMutableSet set];
1692-
hashedObjectsCache = [[NSMutableDictionary alloc] init];
16931595
self.taskQueue = [[PFTaskQueue alloc] init];
16941596
_eventuallyTaskQueue = [[PFTaskQueue alloc] init];
16951597

@@ -2057,7 +1959,6 @@ - (BOOL)isDirty {
20571959

20581960
- (BOOL)isDirtyForKey:(NSString *)key {
20591961
@synchronized (lock) {
2060-
[self checkForChangesToMutableContainer:_estimatedData[key] forKey:key];
20611962
return !![[self unsavedChanges] objectForKey:key];
20621963
}
20631964
}
@@ -2302,7 +2203,6 @@ - (void)revert {
23022203
[_availableKeys intersectSet:persistentKeys];
23032204

23042205
[self rebuildEstimatedData];
2305-
[self checkpointAllMutableContainers];
23062206
}
23072207
}
23082208
}
@@ -2313,7 +2213,6 @@ - (void)revertObjectForKey:(NSString *)key {
23132213
[[self unsavedChanges] removeObjectForKey:key];
23142214
[self rebuildEstimatedData];
23152215
[_availableKeys removeObject:key];
2316-
[self checkpointAllMutableContainers];
23172216
}
23182217
}
23192218
}

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)