avoid unnecessary requests for signatures to remote process

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@29652 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2010-02-16 17:08:47 +00:00
parent b6c0669529
commit 7293e19429
3 changed files with 32 additions and 3 deletions

View file

@ -1,3 +1,9 @@
2010-02-16 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSDistantObject.m:
Cache method signatures to avoid asking remote end for them
repeatedly.
2010-02-16 Wolfgang Lux <wolfgang.lux@gmail.com>
* Source/Additions/Unicode.m (GSToUnicode): Fix bug where

View file

@ -44,7 +44,7 @@ extern "C" {
unsigned _handle;
Protocol *_protocol;
unsigned _counter;
void *_unused;
void *_sigs;
#endif
}

View file

@ -32,6 +32,7 @@
#import "GNUstepBase/DistributedObjects.h"
#import "GNUstepBase/GSObjCRuntime.h"
#import "Foundation/NSDebug.h"
#import "Foundation/NSDictionary.h"
#import "Foundation/NSLock.h"
#import "Foundation/NSPort.h"
#import "Foundation/NSMethodSignature.h"
@ -467,6 +468,7 @@ enum proxyLocation
- (void) dealloc
{
[self finalize];
if (_sigs != 0) [(NSMutableDictionary*)_sigs release];
[super dealloc];
}
@ -632,7 +634,7 @@ enum proxyLocation
if (debug_proxy)
NSLog(@"Created new local=0x%x object 0x%x target 0x%x connection 0x%x\n",
(uintptr_t)self, (uintptr_t)_object, _handle, (uintptr_t)_connection);
(uintptr_t)self, (uintptr_t)_object, _handle, (uintptr_t)_connection);
return self;
}
@ -752,6 +754,15 @@ enum proxyLocation
return [NSMethodSignature signatureWithObjCTypes: types];
}
if (_sigs != 0)
{
NSMutableDictionary *d = (NSMutableDictionary*)_sigs;
NSString *s = NSStringFromSelector(aSelector);
NSMethodSignature *m = [d objectForKey: s];
if (m != nil) return m;
}
{
id m = nil;
id inv;
@ -763,11 +774,23 @@ enum proxyLocation
{
const char *types;
types = [m methodType];
types = [m methodType];
/* Create a local method signature.
*/
m = [NSMethodSignature signatureWithObjCTypes: types];
}
if (m != nil)
{
NSMutableDictionary *d = (NSMutableDictionary*)_sigs;
NSString *s = NSStringFromSelector(aSelector);
if (d == nil)
{
d = [NSMutableDictionary new];
_sigs = (void*)d;
}
[d setObject: m forKey: s];
}
return m;
}
}