Performance tweaks

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@21985 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-Macdonald 2005-11-10 22:40:57 +00:00
parent 8ea1ca503e
commit 38c6dab94b
3 changed files with 23 additions and 4 deletions

View file

@ -25,6 +25,7 @@
#if defined(__MINGW32__)
@interface NSMessagePort(Private)
+ (id) newWithName: (NSString*)name;
- (id) initWithName: (NSString*)name;
- (NSString*) name;
- (void) receivedEventRead;

View file

@ -217,7 +217,7 @@ static void clean_up_names(void)
n = [[self class] _query: name];
NSDebugLLog(@"NSMessagePort", @"got %@", n);
return AUTORELEASE([[NSMessagePort alloc] initWithName: n]);
return AUTORELEASE([NSMessagePort newWithName: n]);
}
- (BOOL) registerPort: (NSPort *)port

View file

@ -125,7 +125,7 @@ static NSRecursiveLock *messagePortLock = nil;
* Maps port name to NSMessagePort objects.
*/
static NSMapTable *ports = 0;
static Class messagePortClass;
static Class messagePortClass = 0;
#if NEED_WORD_ALIGNMENT
static unsigned wordAlign;
@ -186,6 +186,24 @@ static unsigned wordAlign;
}
}
+ (id) newWithName: (NSString*)name
{
NSMessagePort *p;
M_LOCK(messagePortLock);
p = RETAIN((NSMessagePort*)NSMapGet(ports, (void*)name));
if (p == nil)
{
p = [[self alloc] initWithName: name];
}
else
{
[p _setupSendPort];
}
M_UNLOCK(messagePortLock);
return p;
}
- (void) addConnection: (NSConnection*)aConnection
toRunLoop: (NSRunLoop*)aLoop
forMode: (NSString*)aMode
@ -594,7 +612,7 @@ static unsigned wordAlign;
length: 16
encoding: NSASCIIStringEncoding];
NSDebugFLLog(@"NSMessagePort", @"Decoded port as '%@'", n);
rPort = [[NSMessagePort alloc] initWithName: n];
rPort = [messagePortClass newWithName: n];
RELEASE(n);
if (rPort == nil)
{
@ -631,7 +649,7 @@ static unsigned wordAlign;
length: 16
encoding: NSASCIIStringEncoding];
NSDebugFLLog(@"NSMessagePort", @"Decoded port as '%@'", n);
p = [[NSMessagePort alloc] initWithName: n];
p = [messagePortClass newWithName: n];
RELEASE(n);
if (p == nil)
{