Minor performance improvement in keysSortedByValueUsingSelector:

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@3126 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 1998-10-27 09:35:06 +00:00
parent bb6ffeec67
commit 174bf40bae

View file

@ -422,14 +422,14 @@ static Class NSMutableDictionary_concrete_class;
autorelease];
}
struct foo { NSDictionary *d; SEL s; };
struct foo { NSDictionary *d; SEL s; IMP i; };
static int
compareIt(id o1, id o2, void* context)
{
struct foo *f = (struct foo*)context;
o1 = [f->d objectForKey: o1];
o2 = [f->d objectForKey: o2];
o1 = (*f->i)(f->d, @selector(objectForKey:), o1);
o2 = (*f->i)(f->d, @selector(objectForKey:), o2);
return (int)[o1 performSelector: f->s withObject: o2];
}
@ -440,6 +440,7 @@ compareIt(id o1, id o2, void* context)
info.d = self;
info.s = comp;
info.i = [self methodForSelector: @selector(objectForKey:)];
k = [[self allKeys] sortedArrayUsingFunction: compareIt context: &info];
}