Avoid enumerating vim controllers

Don't enumerate vim controllers when processing input since it may
potentially be a huge operation.  If the vim controller array were to be
modified during input processing (should never happen) MacVim would crash.
This commit is contained in:
Bjorn Winckler
2009-04-08 20:38:28 +02:00
parent dd76f85f0b
commit 40263195cb
+13 -7
View File
@@ -2148,13 +2148,19 @@ fsEventCallback(ConstFSEventStreamRef streamRef,
NSDictionary *queues = inputQueues;
inputQueues = [NSMutableDictionary new];
MMVimController *vc;
NSEnumerator *e = [vimControllers objectEnumerator];
while ((vc = [e nextObject])) {
NSNumber *key = [NSNumber numberWithUnsignedInt:[vc identifier]];
NSArray *q = [queues objectForKey:key];
if (q)
[vc processInputQueue:q];
// Pass each input queue on to the vim controller with matching identifier.
NSEnumerator *e = [queues keyEnumerator];
NSNumber *key;
while ((key = [e nextObject])) {
unsigned ukey = [key unsignedIntValue];
int i = 0, count = [vimControllers count];
for (i = 0; i < count; ++i) {
MMVimController *vc = [vimControllers objectAtIndex:i];
if (ukey == [vc identifier]) {
[vc processInputQueue:[queues objectForKey:key]];
break;
}
}
}
[queues release];