mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 08:21:25 +00:00
Improve dictionary lookup for strings.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@3003 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
40af9def9d
commit
38796b2e68
4 changed files with 80 additions and 5 deletions
|
@ -43,6 +43,20 @@
|
|||
|
||||
@implementation NSGString
|
||||
|
||||
static Class immutableClass;
|
||||
static Class mutableClass;
|
||||
|
||||
+ (void) initialize
|
||||
{
|
||||
static int done = 0;
|
||||
if (!done)
|
||||
{
|
||||
done = 1;
|
||||
immutableClass = [NSGString class];
|
||||
mutableClass = [NSGMutableString class];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
if (_free_contents)
|
||||
|
@ -61,6 +75,26 @@
|
|||
return _hash;
|
||||
}
|
||||
|
||||
- (BOOL) isEqual: (id)anObject
|
||||
{
|
||||
Class c;
|
||||
if (anObject == self)
|
||||
return YES;
|
||||
c = [anObject class];
|
||||
if (c == immutableClass || c == mutableClass)
|
||||
{
|
||||
NSGString *other = (NSGString*)anObject;
|
||||
|
||||
if (_hash == 0) [self hash];
|
||||
if (other->_hash == 0) [other hash];
|
||||
if (_hash != other->_hash)
|
||||
return NO;
|
||||
return [self isEqualToString: other];
|
||||
}
|
||||
else
|
||||
return [super isEqual: anObject];
|
||||
}
|
||||
|
||||
// Initializing Newly Allocated Strings
|
||||
|
||||
/* This is the designated initializer for this class. */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue