Index: src/OFConstantString.m ================================================================== --- src/OFConstantString.m +++ src/OFConstantString.m @@ -177,14 +177,14 @@ [self finishInitialization]; return [self mutableCopy]; } /* From protocol OFComparing, but overridden in OFString */ -- (of_comparison_result_t)compare: (OFString *)object +- (of_comparison_result_t)compare: (OFString *)string { [self finishInitialization]; - return [self compare: object]; + return [self compare: string]; } /* From OFObject, but reimplemented in OFString */ - (bool)isEqual: (id)object { @@ -243,14 +243,14 @@ { [self finishInitialization]; return [self cStringLengthWithEncoding: encoding]; } -- (of_comparison_result_t)caseInsensitiveCompare: (OFString *)otherString +- (of_comparison_result_t)caseInsensitiveCompare: (OFString *)string { [self finishInitialization]; - return [self caseInsensitiveCompare: otherString]; + return [self caseInsensitiveCompare: string]; } - (of_unichar_t)characterAtIndex: (size_t)idx { [self finishInitialization]; Index: src/OFData.m ================================================================== --- src/OFData.m +++ src/OFData.m @@ -448,21 +448,18 @@ return false; return true; } -- (of_comparison_result_t)compare: (id )object +- (of_comparison_result_t)compare: (OFData *)data { - OFData *data; int comparison; size_t count, minCount; - if (![(id)object isKindOfClass: [OFData class]]) + if (![data isKindOfClass: [OFData class]]) @throw [OFInvalidArgumentException exception]; - data = (OFData *)object; - if (data.itemSize != _itemSize) @throw [OFInvalidArgumentException exception]; count = data.count; minCount = (_count > count ? count : _count); Index: src/OFDate.m ================================================================== --- src/OFDate.m +++ src/OFDate.m @@ -563,22 +563,18 @@ - (id)copy { return [self retain]; } -- (of_comparison_result_t)compare: (id )object +- (of_comparison_result_t)compare: (OFDate *)date { - OFDate *otherDate; - - if (![(id)object isKindOfClass: [OFDate class]]) + if (![date isKindOfClass: [OFDate class]]) @throw [OFInvalidArgumentException exception]; - otherDate = (OFDate *)object; - - if (self.timeIntervalSince1970 < otherDate.timeIntervalSince1970) + if (self.timeIntervalSince1970 < date.timeIntervalSince1970) return OF_ORDERED_ASCENDING; - if (self.timeIntervalSince1970 > otherDate.timeIntervalSince1970) + if (self.timeIntervalSince1970 > date.timeIntervalSince1970) return OF_ORDERED_DESCENDING; return OF_ORDERED_SAME; } Index: src/OFNumber.m ================================================================== --- src/OFNumber.m +++ src/OFNumber.m @@ -940,18 +940,14 @@ return (number.longLongValue == self.longLongValue); return (number.unsignedLongLongValue == self.unsignedLongLongValue); } -- (of_comparison_result_t)compare: (id )object -{ - OFNumber *number; - - if (![(id)object isKindOfClass: [OFNumber class]]) - @throw [OFInvalidArgumentException exception]; - - number = (OFNumber *)object; +- (of_comparison_result_t)compare: (OFNumber *)number +{ + if (![number isKindOfClass: [OFNumber class]]) + @throw [OFInvalidArgumentException exception]; if (isFloat(self) || isFloat(number)) { double double1 = self.doubleValue; double double2 = number.doubleValue; Index: src/OFString.m ================================================================== --- src/OFString.m +++ src/OFString.m @@ -1512,30 +1512,30 @@ } - (bool)isEqual: (id)object { void *pool; - OFString *otherString; + OFString *string; const of_unichar_t *characters, *otherCharacters; size_t length; if (object == self) return true; if (![object isKindOfClass: [OFString class]]) return false; - otherString = object; + string = object; length = self.length; - if (otherString.length != length) + if (string.length != length) return false; pool = objc_autoreleasePoolPush(); characters = self.characters; - otherCharacters = otherString.characters; + otherCharacters = string.characters; if (memcmp(characters, otherCharacters, length * sizeof(of_unichar_t)) != 0) { objc_autoreleasePoolPop(pool); return false; @@ -1554,31 +1554,29 @@ - (id)mutableCopy { return [[OFMutableString alloc] initWithString: self]; } -- (of_comparison_result_t)compare: (id )object +- (of_comparison_result_t)compare: (OFString *)string { void *pool; - OFString *otherString; const of_unichar_t *characters, *otherCharacters; size_t minimumLength; - if (object == self) + if (string == self) return OF_ORDERED_SAME; - if (![(id)object isKindOfClass: [OFString class]]) + if (![string isKindOfClass: [OFString class]]) @throw [OFInvalidArgumentException exception]; - otherString = (OFString *)object; - minimumLength = (self.length > otherString.length - ? otherString.length : self.length); + minimumLength = (self.length > string.length + ? string.length : self.length); pool = objc_autoreleasePoolPush(); characters = self.characters; - otherCharacters = otherString.characters; + otherCharacters = string.characters; for (size_t i = 0; i < minimumLength; i++) { if (characters[i] > otherCharacters[i]) { objc_autoreleasePoolPop(pool); return OF_ORDERED_DESCENDING; @@ -1590,31 +1588,31 @@ } } objc_autoreleasePoolPop(pool); - if (self.length > otherString.length) + if (self.length > string.length) return OF_ORDERED_DESCENDING; - if (self.length < otherString.length) + if (self.length < string.length) return OF_ORDERED_ASCENDING; return OF_ORDERED_SAME; } -- (of_comparison_result_t)caseInsensitiveCompare: (OFString *)otherString +- (of_comparison_result_t)caseInsensitiveCompare: (OFString *)string { void *pool = objc_autoreleasePoolPush(); const of_unichar_t *characters, *otherCharacters; size_t length, otherLength, minimumLength; - if (otherString == self) + if (string == self) return OF_ORDERED_SAME; characters = self.characters; - otherCharacters = otherString.characters; + otherCharacters = string.characters; length = self.length; - otherLength = otherString.length; + otherLength = string.length; minimumLength = (length > otherLength ? otherLength : length); for (size_t i = 0; i < minimumLength; i++) { of_unichar_t c = characters[i]; Index: src/OFTimer.m ================================================================== --- src/OFTimer.m +++ src/OFTimer.m @@ -504,18 +504,14 @@ #endif [super dealloc]; } -- (of_comparison_result_t)compare: (id )object -{ - OFTimer *timer; - - if (![(id)object isKindOfClass: [OFTimer class]]) - @throw [OFInvalidArgumentException exception]; - - timer = (OFTimer *)object; +- (of_comparison_result_t)compare: (OFTimer *)timer +{ + if (![timer isKindOfClass: [OFTimer class]]) + @throw [OFInvalidArgumentException exception]; return [_fireDate compare: timer->_fireDate]; } - (void)of_setInRunLoop: (OFRunLoop *)runLoop mode: (of_run_loop_mode_t)mode Index: src/OFUTF8String.m ================================================================== --- src/OFUTF8String.m +++ src/OFUTF8String.m @@ -772,54 +772,51 @@ return _s->cStringLength; } - (bool)isEqual: (id)object { - OFUTF8String *otherString; + OFUTF8String *string; if (object == self) return true; if (![object isKindOfClass: [OFString class]]) return false; - otherString = object; + string = object; - if (otherString.UTF8StringLength != _s->cStringLength || - otherString.length != _s->length) + if (string.UTF8StringLength != _s->cStringLength || + string.length != _s->length) + return false; + + if (([string isKindOfClass: [OFUTF8String class]] || + [string isKindOfClass: [OFMutableUTF8String class]]) && + _s->hashed && string->_s->hashed && _s->hash != string->_s->hash) return false; - if (([otherString isKindOfClass: [OFUTF8String class]] || - [otherString isKindOfClass: [OFMutableUTF8String class]]) && - _s->hashed && otherString->_s->hashed && - _s->hash != otherString->_s->hash) - return false; - - if (strcmp(_s->cString, otherString.UTF8String) != 0) + if (strcmp(_s->cString, string.UTF8String) != 0) return false; return true; } -- (of_comparison_result_t)compare: (id )object +- (of_comparison_result_t)compare: (OFString *)string { - OFString *otherString; size_t otherCStringLength, minimumCStringLength; int compare; - if (object == self) + if (string == self) return OF_ORDERED_SAME; - if (![(id)object isKindOfClass: [OFString class]]) + if (![string isKindOfClass: [OFString class]]) @throw [OFInvalidArgumentException exception]; - otherString = (OFString *)object; - otherCStringLength = otherString.UTF8StringLength; + otherCStringLength = string.UTF8StringLength; minimumCStringLength = (_s->cStringLength > otherCStringLength ? otherCStringLength : _s->cStringLength); - if ((compare = memcmp(_s->cString, otherString.UTF8String, + if ((compare = memcmp(_s->cString, string.UTF8String, minimumCStringLength)) == 0) { if (_s->cStringLength > otherCStringLength) return OF_ORDERED_DESCENDING; if (_s->cStringLength < otherCStringLength) return OF_ORDERED_ASCENDING; @@ -830,27 +827,24 @@ return OF_ORDERED_DESCENDING; else return OF_ORDERED_ASCENDING; } -- (of_comparison_result_t)caseInsensitiveCompare: (OFString *)otherString +- (of_comparison_result_t)caseInsensitiveCompare: (OFString *)string { const char *otherCString; size_t otherCStringLength, minimumCStringLength; #ifdef OF_HAVE_UNICODE_TABLES size_t i, j; #endif int compare; - if (otherString == self) + if (string == self) return OF_ORDERED_SAME; - if (![otherString isKindOfClass: [OFString class]]) - @throw [OFInvalidArgumentException exception]; - - otherCString = otherString.UTF8String; - otherCStringLength = otherString.UTF8StringLength; + otherCString = string.UTF8String; + otherCStringLength = string.UTF8StringLength; #ifdef OF_HAVE_UNICODE_TABLES if (!_s->isUTF8) { #endif minimumCStringLength = (_s->cStringLength > otherCStringLength