mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 08:21:25 +00:00
Optimise test for dictionary equality
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@15973 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
bfed503388
commit
64d7feafd2
4 changed files with 93 additions and 2 deletions
|
@ -244,6 +244,42 @@ static SEL objSel;
|
|||
return self;
|
||||
}
|
||||
|
||||
- (BOOL) isEqualToDictionary: (NSDictionary*)other
|
||||
{
|
||||
unsigned count;
|
||||
|
||||
if (other == self)
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
count = map.nodeCount;
|
||||
if (count == [other count])
|
||||
{
|
||||
if (count > 0)
|
||||
{
|
||||
GSIMapEnumerator_t enumerator;
|
||||
GSIMapNode node;
|
||||
IMP otherObj = [other methodForSelector: objSel];
|
||||
|
||||
enumerator = GSIMapEnumeratorForMap(&map);
|
||||
while ((node = GSIMapEnumeratorNextNode(&enumerator)) != 0)
|
||||
{
|
||||
id o1 = node->value.obj;
|
||||
id o2 = (*otherObj)(other, objSel, node->key.obj);
|
||||
|
||||
if (o1 != o2 && [o1 isEqual: o2] == NO)
|
||||
{
|
||||
GSIMapEndEnumerator(&enumerator);
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
GSIMapEndEnumerator(&enumerator);
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (NSEnumerator*) keyEnumerator
|
||||
{
|
||||
return AUTORELEASE([[GSDictionaryKeyEnumerator allocWithZone:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue