Index: src/OFString.m ================================================================== --- src/OFString.m +++ src/OFString.m @@ -1034,10 +1034,13 @@ { OFAutoreleasePool *pool; OFString *otherString; const of_unichar_t *unicodeString, *otherUnicodeString; size_t length; + + if (object == self) + return YES; if (![object isKindOfClass: [OFString class]]) return NO; otherString = object; @@ -1077,10 +1080,13 @@ OFAutoreleasePool *pool; OFString *otherString; const of_unichar_t *unicodeString, *otherUnicodeString; size_t i, minimumLength; + if (object == self) + return OF_ORDERED_SAME; + if (![object isKindOfClass: [OFString class]]) @throw [OFInvalidArgumentException exceptionWithClass: isa selector: _cmd]; otherString = object; @@ -1117,10 +1123,13 @@ - (of_comparison_result_t)caseInsensitiveCompare: (OFString*)otherString { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; const of_unichar_t *string, *otherUnicodeString; size_t i, length, otherLength, minimumLength; + + if (otherString == self) + return OF_ORDERED_SAME; string = [self unicodeString]; otherUnicodeString = [otherString unicodeString]; length = [self length]; otherLength = [otherString length]; Index: src/OFString_UTF8.m ================================================================== --- src/OFString_UTF8.m +++ src/OFString_UTF8.m @@ -587,10 +587,13 @@ } - (BOOL)isEqual: (id)object { OFString_UTF8 *otherString; + + if (object == self) + return YES; if (![object isKindOfClass: [OFString class]]) return NO; otherString = object; @@ -609,10 +612,13 @@ { OFString *otherString; size_t otherCStringLength, minimumCStringLength; int compare; + if (object == self) + return OF_ORDERED_SAME; + if (![object isKindOfClass: [OFString class]]) @throw [OFInvalidArgumentException exceptionWithClass: isa selector: _cmd]; otherString = object; @@ -638,10 +644,13 @@ - (of_comparison_result_t)caseInsensitiveCompare: (OFString*)otherString { const char *otherCString; size_t i, j, otherCStringLength, minimumCStringLength; int compare; + + if (otherString == self) + return OF_ORDERED_SAME; if (![otherString isKindOfClass: [OFString class]]) @throw [OFInvalidArgumentException exceptionWithClass: isa selector: _cmd];