Optimisation changes

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@4103 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 1999-04-20 16:28:04 +00:00
parent 5f299bcb7b
commit 917f1542c2
12 changed files with 654 additions and 527 deletions

View file

@ -293,23 +293,23 @@ static int messages_received_count;
*/
+ (NSConnection*) defaultConnection
{
static NSString* tkey = @"NSConnectionThreadKey";
NSConnection* c;
NSThread* t;
static NSString *tkey = @"NSConnectionThreadKey";
NSConnection *c;
NSMutableDictionary *d;
t = GSCurrentThread();
c = (NSConnection*)[[t threadDictionary] objectForKey:tkey];
d = GSCurrentThreadDictionary();
c = (NSConnection*)[d objectForKey:tkey];
if (c != nil && [c isValid] == NO) {
/*
* If the default connection for this thread has been invalidated -
* release it and create a new one.
*/
[[t threadDictionary] removeObjectForKey:tkey];
[d removeObjectForKey:tkey];
c = nil;
}
if (c == nil) {
c = [NSConnection new];
[[t threadDictionary] setObject:c forKey:tkey];
[d setObject:c forKey:tkey];
[c release]; /* retained in dictionary. */
}
return c;