Skip to content

Commit ac5bf5c

Browse files
committed
Removed 'mutable containers' functionality.
1 parent 8b2b57b commit ac5bf5c

File tree

5 files changed

+1
-140
lines changed

5 files changed

+1
-140
lines changed

Parse/Internal/Object/PFObjectPrivate.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,6 @@
212212
///--------------------------------------
213213
#pragma mark - Data helpers
214214
///--------------------------------------
215-
- (void)checkForChangesToMutableContainers;
216215
- (void)rebuildEstimatedData;
217216

218217
///--------------------------------------

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 & 101 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
@@ -653,7 +631,6 @@ - (BFTask *)_saveChildrenInBackgroundWithCurrentUser:(PFUser *)currentUser sessi
653631

654632
- (BOOL)isDirty:(BOOL)considerChildren {
655633
@synchronized (lock) {
656-
[self checkForChangesToMutableContainers];
657634
if (self._state.deleted || dirty || [self _hasChanges]) {
658635
return YES;
659636
}
@@ -680,62 +657,6 @@ - (void)_setDirty:(BOOL)aDirty {
680657
}
681658
}
682659

683-
///--------------------------------------
684-
#pragma mark - Mutable container management
685-
///--------------------------------------
686-
687-
- (void)checkpointAllMutableContainers {
688-
@synchronized (lock) {
689-
[_estimatedData enumerateKeysAndObjectsUsingBlock:^(NSString *key, id obj, BOOL *stop) {
690-
[self checkpointMutableContainer:obj];
691-
}];
692-
}
693-
}
694-
695-
- (void)checkpointMutableContainer:(id)object {
696-
@synchronized (lock) {
697-
if (PFObjectValueIsKindOfMutableContainerClass(object)) {
698-
[hashedObjectsCache setObject:[PFJSONCacheItem cacheFromObject:object]
699-
forKey:[NSValue valueWithNonretainedObject:object]];
700-
}
701-
}
702-
}
703-
704-
- (void)checkForChangesToMutableContainer:(id)object forKey:(NSString *)key {
705-
@synchronized (lock) {
706-
// If this is a mutable container, we should check its contents.
707-
if (PFObjectValueIsKindOfMutableContainerClass(object)) {
708-
PFJSONCacheItem *oldCacheItem = [hashedObjectsCache objectForKey:[NSValue valueWithNonretainedObject:object]];
709-
if (!oldCacheItem) {
710-
[NSException raise:NSInternalInconsistencyException
711-
format:@"PFObject contains container item that isn't cached."];
712-
} else {
713-
PFJSONCacheItem *newCacheItem = [PFJSONCacheItem cacheFromObject:object];
714-
if (![oldCacheItem isEqual:newCacheItem]) {
715-
// A mutable container changed out from under us. Treat it as a set operation.
716-
[self setObject:object forKey:key];
717-
}
718-
}
719-
} else {
720-
[hashedObjectsCache removeObjectForKey:[NSValue valueWithNonretainedObject:object]];
721-
}
722-
}
723-
}
724-
725-
- (void)checkForChangesToMutableContainers {
726-
@synchronized (lock) {
727-
NSMutableArray *unexaminedCacheKeys = [[hashedObjectsCache allKeys] mutableCopy];
728-
NSDictionary *reachableData = _estimatedData.dictionaryRepresentation;
729-
[reachableData enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
730-
[unexaminedCacheKeys removeObject:[NSValue valueWithNonretainedObject:obj]];
731-
[self checkForChangesToMutableContainer:obj forKey:key];
732-
}];
733-
734-
// Remove unchecked cache entries.
735-
[hashedObjectsCache removeObjectsForKeys:unexaminedCacheKeys];
736-
}
737-
}
738-
739660
///--------------------------------------
740661
#pragma mark - Data Availability
741662
///--------------------------------------
@@ -942,7 +863,6 @@ + (BFTask *)_migrateObjectInBackgroundFromFile:(NSString *)fileName
942863
- (NSDictionary *)RESTDictionaryWithObjectEncoder:(PFEncoder *)objectEncoder
943864
operationSetUUIDs:(NSArray **)operationSetUUIDs {
944865
@synchronized (lock) {
945-
[self checkForChangesToMutableContainers];
946866
PFObjectState *state = self._state;
947867
return [self RESTDictionaryWithObjectEncoder:objectEncoder
948868
operationSetUUIDs:operationSetUUIDs
@@ -1081,15 +1001,11 @@ - (void)mergeFromRESTDictionary:(NSDictionary *)object withDecoder:(PFDecoder *)
10811001
if ([key isEqualToString:PFObjectACLRESTKey]) {
10821002
PFACL *acl = [PFACL ACLWithDictionary:obj];
10831003
[state setServerDataObject:acl forKey:PFObjectACLRESTKey];
1084-
[self checkpointMutableContainer:acl];
10851004
return;
10861005
}
10871006

10881007
// Should be decoded
10891008
id decodedObject = [decoder decodeObject:obj];
1090-
if (PFObjectValueIsKindOfMutableContainerClass(decodedObject)) {
1091-
[self checkpointMutableContainer:decodedObject];
1092-
}
10931009
[state setServerDataObject:decodedObject forKey:key];
10941010
}];
10951011
if (state.updatedAt == nil && state.createdAt != nil) {
@@ -1108,7 +1024,6 @@ - (void)mergeFromRESTDictionary:(NSDictionary *)object withDecoder:(PFDecoder *)
11081024
}
11091025
}
11101026
[self rebuildEstimatedData];
1111-
[self checkpointAllMutableContainers];
11121027
}
11131028
}
11141029

@@ -1207,8 +1122,6 @@ - (BFTask *)_enqueueSaveEventuallyOperationAsync:(PFOperationSet *)operationSet
12071122
- (NSMutableDictionary *)_convertToDictionaryForSaving:(PFOperationSet *)changes
12081123
withObjectEncoder:(PFEncoder *)encoder {
12091124
@synchronized (lock) {
1210-
[self checkForChangesToMutableContainers];
1211-
12121125
NSMutableDictionary *serialized = [NSMutableDictionary dictionary];
12131126
[changes enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
12141127
serialized[key] = obj;
@@ -1223,12 +1136,11 @@ - (NSMutableDictionary *)_convertToDictionaryForSaving:(PFOperationSet *)changes
12231136
*/
12241137
- (void)performOperation:(PFFieldOperation *)operation forKey:(NSString *)key {
12251138
@synchronized (lock) {
1226-
id newValue = [_estimatedData applyFieldOperation:operation forKey:key];
1139+
[_estimatedData applyFieldOperation:operation forKey:key];
12271140

12281141
PFFieldOperation *oldOperation = [[self unsavedChanges] objectForKey:key];
12291142
PFFieldOperation *newOperation = [operation mergeWithPrevious:oldOperation];
12301143
[[self unsavedChanges] setObject:newOperation forKey:key];
1231-
[self checkpointMutableContainer:newValue];
12321144
[_availableKeys addObject:key];
12331145
}
12341146
}
@@ -1294,7 +1206,6 @@ - (PFObject *)mergeFromObject:(PFObject *)other {
12941206
state.updatedAt = other.updatedAt;
12951207
state.serverData = [other._state.serverData mutableCopy];
12961208
self._state = state;
1297-
[self checkpointAllMutableContainers];
12981209

12991210
dirty = NO;
13001211

@@ -1305,13 +1216,11 @@ - (PFObject *)mergeFromObject:(PFObject *)other {
13051216

13061217
- (void)_mergeAfterFetchWithResult:(NSDictionary *)result decoder:(PFDecoder *)decoder completeData:(BOOL)completeData {
13071218
@synchronized (lock) {
1308-
[self checkForChangesToMutableContainers];
13091219
[self _mergeFromServerWithResult:result decoder:decoder completeData:completeData];
13101220
if (completeData) {
13111221
[self removeOldKeysAfterFetch:result];
13121222
}
13131223
[self rebuildEstimatedData];
1314-
[self checkpointAllMutableContainers];
13151224
}
13161225
}
13171226

@@ -1340,16 +1249,12 @@ - (void)_mergeAfterSaveWithResult:(NSDictionary *)result decoder:(PFDecoder *)de
13401249
PFOperationSet *operationsForNextSave = operationSetQueue[0];
13411250
[operationsForNextSave mergeOperationSet:operationsBeforeSave];
13421251
} else {
1343-
// Merge the data from the save and the data from the server into serverData.
1344-
[self checkForChangesToMutableContainers];
1345-
13461252
PFMutableObjectState *state = [self._state mutableCopy];
13471253
[state applyOperationSet:operationsBeforeSave];
13481254
self._state = state;
13491255

13501256
[self _mergeFromServerWithResult:result decoder:decoder completeData:NO];
13511257
[self rebuildEstimatedData];
1352-
[self checkpointAllMutableContainers];
13531258
}
13541259
}
13551260
}
@@ -1371,7 +1276,6 @@ - (void)_mergeFromServerWithResult:(NSDictionary *)result decoder:(PFDecoder *)d
13711276
} else if ([key isEqualToString:PFObjectACLRESTKey]) {
13721277
PFACL *acl = [PFACL ACLWithDictionary:obj];
13731278
[state setServerDataObject:acl forKey:key];
1374-
[self checkpointMutableContainer:acl];
13751279
} else {
13761280
[state setServerDataObject:[decoder decodeObject:obj] forKey:key];
13771281
}
@@ -1665,7 +1569,6 @@ - (instancetype)init {
16651569
_estimatedData = [PFObjectEstimatedData estimatedDataFromServerData:_pfinternal_state.serverData
16661570
operationSetQueue:operationSetQueue];
16671571
_availableKeys = [NSMutableSet set];
1668-
hashedObjectsCache = [[NSMutableDictionary alloc] init];
16691572
self.taskQueue = [[PFTaskQueue alloc] init];
16701573
_eventuallyTaskQueue = [[PFTaskQueue alloc] init];
16711574

@@ -2011,7 +1914,6 @@ - (BOOL)isDirty {
20111914

20121915
- (BOOL)isDirtyForKey:(NSString *)key {
20131916
@synchronized (lock) {
2014-
[self checkForChangesToMutableContainer:_estimatedData[key] forKey:key];
20151917
return !![[self unsavedChanges] objectForKey:key];
20161918
}
20171919
}
@@ -2256,7 +2158,6 @@ - (void)revert {
22562158
[_availableKeys intersectSet:persistentKeys];
22572159

22582160
[self rebuildEstimatedData];
2259-
[self checkpointAllMutableContainers];
22602161
}
22612162
}
22622163
}
@@ -2267,7 +2168,6 @@ - (void)revertObjectForKey:(NSString *)key {
22672168
[[self unsavedChanges] removeObjectForKey:key];
22682169
[self rebuildEstimatedData];
22692170
[_availableKeys removeObject:key];
2270-
[self checkpointAllMutableContainers];
22712171
}
22722172
}
22732173
}

Parse/PFUser.m

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

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

467-
[self checkForChangesToMutableContainers];
468467
@synchronized ([currentUser lock]) {
469468
NSString *oldUsername = [currentUser.username copy];
470469
NSString *oldPassword = [currentUser.password copy];
471470
NSArray *oldAnonymousData = currentUser.authData[[PFAnonymousAuthenticationProvider authType]];
472471

473-
[currentUser checkForChangesToMutableContainers];
474-
475472
// Move the changes to this object over to the currentUser object.
476473
PFOperationSet *selfOperations = operationSetQueue[0];
477474
[operationSetQueue removeAllObjects];

0 commit comments

Comments
 (0)