Skip to content

Commit

Permalink
Back RKEntityByAttributeCache with an NSMutableSet instead of an …
Browse files Browse the repository at this point in the history
…`NSMutableDictionary` for performance. refs #1232
  • Loading branch information
blakewatters authored and scraton committed Apr 24, 2013
1 parent cfb4f7b commit f728d95
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions Code/CoreData/RKEntityByAttributeCache.m
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,9 @@ - (NSSet *)objectsWithAttributeValues:(NSDictionary *)attributeValues inContext:
NSMutableSet *objects = [NSMutableSet set];
NSArray *cacheKeys = RKCacheKeysForEntityFromAttributeValues(self.entity, attributeValues);
for (NSString *cacheKey in cacheKeys) {
NSArray *objectIDs = nil;
NSSet *objectIDs = nil;
@synchronized(self.cacheKeysToObjectIDs) {
objectIDs = [[NSArray alloc] initWithArray:[self.cacheKeysToObjectIDs objectForKey:cacheKey] copyItems:YES];
objectIDs = [[NSSet alloc] initWithSet:[self.cacheKeysToObjectIDs objectForKey:cacheKey] copyItems:YES];
}
if ([objectIDs count]) {
/**
Expand Down Expand Up @@ -279,13 +279,13 @@ - (void)setObjectID:(NSManagedObjectID *)objectID forAttributeValues:(NSDictiona
[self.lock lock];
if (attributeValues && [attributeValues count]) {
NSString *cacheKey = RKCacheKeyForEntityWithAttributeValues(self.entity, attributeValues);
NSMutableArray *objectIDs = [self.cacheKeysToObjectIDs objectForKey:cacheKey];
NSMutableSet *objectIDs = [self.cacheKeysToObjectIDs objectForKey:cacheKey];
if (objectIDs) {
if (! [objectIDs containsObject:objectID]) {
[objectIDs addObject:objectID];
}
} else {
objectIDs = [NSMutableArray arrayWithObject:objectID];
objectIDs = [NSMutableSet setWithObject:objectID];
}

if (nil == self.cacheKeysToObjectIDs) self.cacheKeysToObjectIDs = [NSMutableDictionary dictionary];
Expand All @@ -302,7 +302,7 @@ - (void)removeObjectID:(NSManagedObjectID *)objectID forAttributeValues:(NSDicti
if (attributeValues && [attributeValues count]) {
NSArray *cacheKeys = RKCacheKeysForEntityFromAttributeValues(self.entity, attributeValues);
for (NSString *cacheKey in cacheKeys) {
NSMutableArray *objectIDs = [self.cacheKeysToObjectIDs objectForKey:cacheKey];
NSMutableSet *objectIDs = [self.cacheKeysToObjectIDs objectForKey:cacheKey];
if (objectIDs && [objectIDs containsObject:objectID]) {
[objectIDs removeObject:objectID];
}
Expand Down

0 comments on commit f728d95

Please sign in to comment.