diff --git a/Source/NSGCString.m b/Source/NSGCString.m index 4c4d358bf..08c3b0e16 100644 --- a/Source/NSGCString.m +++ b/Source/NSGCString.m @@ -267,16 +267,48 @@ static Class mutableClass; return [NSString defaultCStringEncoding]; } +- (BOOL) isEqual: (id)anObject +{ + Class c; + if (anObject == self) + return YES; + c = ((NSGCString*)anObject)->isa; /* Hack. */ + if (c == immutableClass || c == mutableClass) + { + NSGCString *other = (NSGCString*)anObject; + + if (_count != other->_count) + return NO; + if (_hash == 0) + if ((_hash = [super hash]) == 0) + _hash = 0xffffffff; + if (other->_hash == 0) [other hash]; + if (_hash != other->_hash) + return NO; + if (memcmp(_contents_chars, other->_contents_chars, _count) != 0) + return NO; + return YES; + } + else if ([c isKindOfClass: [NSString class]]) + return [super isEqualToString: (NSString*)anObject]; + else + return [super isEqual: anObject]; +} + - (BOOL) isEqualToString: (NSString*)aString { - Class c = [aString class]; + Class c; + + c = ((NSGCString*)aString)->isa; /* Hack. */ if (c == immutableClass || c == mutableClass) { NSGCString *other = (NSGCString*)aString; if (_count != other->_count) return NO; - if (_hash && other->_hash && (_hash != other->_hash)) + if (_hash == 0) [self hash]; + if (other->_hash == 0) [other hash]; + if (_hash != other->_hash) return NO; if (memcmp(_contents_chars, other->_contents_chars, _count) != 0) return NO; @@ -284,7 +316,6 @@ static Class mutableClass; } else return [super isEqualToString: aString]; - return YES; } diff --git a/Source/NSGString.m b/Source/NSGString.m index 0308ca469..f9983c2d0 100644 --- a/Source/NSGString.m +++ b/Source/NSGString.m @@ -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. */ diff --git a/Source/NSString.m b/Source/NSString.m index b54ad0054..874227484 100644 --- a/Source/NSString.m +++ b/Source/NSString.m @@ -1406,7 +1406,7 @@ else { if (anObject == self) return YES; - if ([anObject isKindOf:[NSString class]]) + if ([anObject isKindOfClass:[NSString class]] == YES) return [self isEqualToString:anObject]; return NO; } diff --git a/Source/o_map.m b/Source/o_map.m index 48d9347ff..2bd89b660 100644 --- a/Source/o_map.m +++ b/Source/o_map.m @@ -562,12 +562,22 @@ o_map_key_at_key(o_map_t *map, const void *key) const void * o_map_value_at_key(o_map_t *map, const void *key) { +#if 0 const void *value; /* Use the grandfather function above... */ o_map_key_and_value_at_key(map, 0, &value, key); - return value; +#else + o_map_node_t *node; + + /* Try and find the node for KEY. */ + node = _o_map_node_for_key(map, key); + + if (node != 0) + return node->value; + return 0; +#endif } const void **