Merge pull request #1787 from BlairDuncan/CPDictionaryController

minor optimization so that newObject and includedKeys use the same code
This commit is contained in:
aparajita
2013-02-19 23:55:11 -08:00
+18 -16
View File
@@ -57,13 +57,20 @@
while ([keys containsObject:newKey])
newKey = [CPString stringWithFormat:@"%@%i", _initialKey, ++count];
[_contentDictionary setObject:_initialValue forKey:newKey];
return [self _newObjectWithKey:newKey value:_initialValue];
}
var keyValuePairProtocol = [_CPDictionaryControllerKeyValuePair new];
keyValuePairProtocol._key = newKey;
keyValuePairProtocol._dictionary = _contentDictionary;
keyValuePairProtocol._controller = self;
return keyValuePairProtocol;
- (id)_newObjectWithKey:(CPString)aKey value:(id)aValue
{
var aNewObject = [_CPDictionaryControllerKeyValuePair new];
aNewObject._dictionary = _contentDictionary;
aNewObject._controller = self;
aNewObject._key = aKey;
if (aValue !== nil)
[aNewObject setValue:aValue];
return aNewObject
}
- (CPDictionary)contentDictionary
@@ -90,21 +97,13 @@
obj;
while ((obj = [iter nextObject]) !== nil)
{
if (![_excludedKeys containsObject:obj])
{
var keyValuePairProtocol = [_CPDictionaryControllerKeyValuePair new];
keyValuePairProtocol._key = obj;
keyValuePairProtocol._dictionary = _contentDictionary;
keyValuePairProtocol._controller = self;
[array addObject:keyValuePairProtocol];
}
}
[array addObject:[self _newObjectWithKey:obj value:nil]];
[super setContent:array];
}
@end
@@ -138,6 +137,9 @@ var CPIncludedKeys = @"CPIncludedKeys",
@end
@implementation _CPDictionaryControllerKeyValuePair : CPObject
{
CPString _key @accessors(property=key);