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:
CaS 2005-11-10 22:40:57 +00:00
parent 252b778407
commit e848a285c4
3 changed files with 23 additions and 4 deletions

View file

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

View file

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

View file

@ -125,7 +125,7 @@ static NSRecursiveLock *messagePortLock = nil;
* Maps port name to NSMessagePort objects. * Maps port name to NSMessagePort objects.
*/ */
static NSMapTable *ports = 0; static NSMapTable *ports = 0;
static Class messagePortClass; static Class messagePortClass = 0;
#if NEED_WORD_ALIGNMENT #if NEED_WORD_ALIGNMENT
static unsigned wordAlign; 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 - (void) addConnection: (NSConnection*)aConnection
toRunLoop: (NSRunLoop*)aLoop toRunLoop: (NSRunLoop*)aLoop
forMode: (NSString*)aMode forMode: (NSString*)aMode
@ -594,7 +612,7 @@ static unsigned wordAlign;
length: 16 length: 16
encoding: NSASCIIStringEncoding]; encoding: NSASCIIStringEncoding];
NSDebugFLLog(@"NSMessagePort", @"Decoded port as '%@'", n); NSDebugFLLog(@"NSMessagePort", @"Decoded port as '%@'", n);
rPort = [[NSMessagePort alloc] initWithName: n]; rPort = [messagePortClass newWithName: n];
RELEASE(n); RELEASE(n);
if (rPort == nil) if (rPort == nil)
{ {
@ -631,7 +649,7 @@ static unsigned wordAlign;
length: 16 length: 16
encoding: NSASCIIStringEncoding]; encoding: NSASCIIStringEncoding];
NSDebugFLLog(@"NSMessagePort", @"Decoded port as '%@'", n); NSDebugFLLog(@"NSMessagePort", @"Decoded port as '%@'", n);
p = [[NSMessagePort alloc] initWithName: n]; p = [messagePortClass newWithName: n];
RELEASE(n); RELEASE(n);
if (p == nil) if (p == nil)
{ {