* EOControl/EOGlobalID.m (-[EOGlobalID copyWithZone:]): Optimize

to return self as GIDs are immutable and they are used as dictionary
	keys which are generally copied.
	(-[EOTemporaryGlobalID copyWithZone:]): Remove.
	(-[EOTemporaryGlobalID description]): Implement.
	* EOControl/EOKeyGlobalID.m (-[EOKeyGlobalID copyWithZone:]): Remove.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@22179 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
ayers 2005-12-18 22:34:54 +00:00
parent 59216ebe78
commit 009eeba60a
3 changed files with 27 additions and 28 deletions

View file

@ -14,6 +14,13 @@
* EOControl/EOEventCenter.[hm]: New files.
* EOControl/EOControl.h: Add EOEvent.h and EOEventCenter.h.
* EOControl/GNUmakefile: Add EOEvent.h/m and EOEventCenter.h/m.
* EOControl/EOGlobalID.m (-[EOGlobalID copyWithZone:]): Optimize
to return self as GIDs are immutable and they are used as dictionary
keys which are generally copied.
(-[EOTemporaryGlobalID copyWithZone:]): Remove.
(-[EOTemporaryGlobalID description]): Implement.
* EOControl/EOKeyGlobalID.m (-[EOKeyGlobalID copyWithZone:]): Remove.
2005-12-05 David Ayers <d.ayers@inode.at>

View file

@ -87,9 +87,7 @@ NSString *EOGlobalIDChangedNotification = @"EOGlobalIDChangedNotification";
- (id)copyWithZone: (NSZone *)zone
{
EOGlobalID *gid = [[[self class] alloc] init];
return gid;
return RETAIN(self);
}
@end
@ -99,7 +97,6 @@ NSString *EOGlobalIDChangedNotification = @"EOGlobalIDChangedNotification";
static unsigned short sequence = (unsigned short)-1;
+ (EOTemporaryGlobalID *)temporaryGlobalID
{
return [[[self alloc] init] autorelease];
@ -223,14 +220,28 @@ static unsigned short sequence = (unsigned short)-1;
return self;
}
- (id)copyWithZone: (NSZone *)zone
- (NSString *)description
{
EOTemporaryGlobalID *gid = [super copyWithZone:zone];
unsigned char dst[(EOUniqueBinaryKeyLength<<1) /* 2 x buffer */
+ (EOUniqueBinaryKeyLength>>2) /* + 1 space per 4 byte */
+ 1]; /* + terminator */
unsigned int i,j;
gid->_refCount = _refCount;
memcpy(gid->_bytes, _bytes, sizeof(_bytes));
#define num2char(num) ((num) < 0xa ? ((num)+'0') : ((num)+0x57))
for (i = 0, j = 0; i < EOUniqueBinaryKeyLength; i++, j++)
{
dst[j] = num2char((_bytes[i]>>4) & 0x0f);
dst[++j] = num2char(_bytes[i] & 0x0f);
return gid;
/* Insert a space per 4 bytes. */
if ((i & 3) == 3 && i < EOUniqueBinaryKeyLength-1)
{
dst[++j] = ' ';
}
}
dst[j] = 0;
return [NSString stringWithFormat: @"<%@ %s>",
GSClassNameFromObject(self), dst];
}
@end

View file

@ -188,25 +188,6 @@ RCS_ID("$Id$")
return self;
}
- (id)copyWithZone: (NSZone *)zone
{
EOKeyGlobalID *gid = [super copyWithZone: zone];
int i;
ASSIGN(gid->_entityName, _entityName);
gid->_keyCount = _keyCount;
gid->_keyValues = NSZoneMalloc(zone, _keyCount * sizeof(id));
for (i = 0; i < _keyCount; i++)
{
gid->_keyValues[i] = nil;
ASSIGN(gid->_keyValues[i], _keyValues[i]);
}
return gid;
}
- (BOOL) isFinal
{
// [self notImplemented:_cmd]; //TODO