@@ -299,11 +299,11 @@ - (bool)isEqual: (id)object { OFDictionary *otherDictionary; void *pool; - OFEnumerator *enumerator; + OFEnumerator *keyEnumerator, *objectEnumerator; id key; if (![object isKindOfClass: [OFDictionary class]]) return false; @@ -312,16 +312,17 @@ if ([otherDictionary count] != [self count]) return false; pool = objc_autoreleasePoolPush(); - enumerator = [self keyEnumerator]; - while ((key = [enumerator nextObject]) != nil) { - id object = [otherDictionary objectForKey: key]; + keyEnumerator = [self keyEnumerator]; + objectEnumerator = [self objectEnumerator]; + while ((key = [keyEnumerator nextObject]) != nil && + (object = [objectEnumerator nextObject]) != nil) { + id otherObject = [otherDictionary objectForKey: key]; - if (object == nil || - ![object isEqual: [self objectForKey: key]]) { + if (otherObject == nil || ![otherObject isEqual: object]) { objc_autoreleasePoolPop(pool); return false; } } @@ -338,12 +339,12 @@ if (object == nil) return false; pool = objc_autoreleasePoolPush(); + enumerator = [self objectEnumerator]; - while ((currentObject = [enumerator nextObject]) != nil) { if ([currentObject isEqual: object]) { objc_autoreleasePoolPop(pool); return true; } @@ -362,12 +363,12 @@ if (object == nil) return false; pool = objc_autoreleasePoolPush(); + enumerator = [self objectEnumerator]; - while ((currentObject = [enumerator nextObject]) != nil) { if (currentObject == object) { objc_autoreleasePoolPop(pool); return true; } @@ -379,21 +380,16 @@ } - (OFArray*)allKeys { OFMutableArray *ret = [OFMutableArray arrayWithCapacity: [self count]]; - void *pool = objc_autoreleasePoolPush(); - OFEnumerator *enumerator = [self keyEnumerator]; - id key; - while ((key = [enumerator nextObject]) != nil) + for (id key in self) [ret addObject: key]; [ret makeImmutable]; - objc_autoreleasePoolPop(pool); - return ret; } - (OFArray*)allObjects { @@ -427,11 +423,11 @@ count: (int)count_ { OF_UNRECOGNIZED_SELECTOR } -#if defined(OF_HAVE_BLOCKS) && defined(OF_HAVE_FAST_ENUMERATION) +#ifdef OF_HAVE_BLOCKS - (void)enumerateKeysAndObjectsUsingBlock: (of_dictionary_enumeration_block_t)block { bool stop = false; @@ -440,13 +436,11 @@ if (stop) break; } } -#endif -#ifdef OF_HAVE_BLOCKS - (OFDictionary*)mappedDictionaryUsingBlock: (of_dictionary_map_block_t)block { OFMutableDictionary *new = [OFMutableDictionary dictionary]; [self enumerateKeysAndObjectsUsingBlock: ^ (id key, id object, @@ -479,17 +473,19 @@ #endif - (uint32_t)hash { void *pool = objc_autoreleasePoolPush(); - OFEnumerator *enumerator = [self keyEnumerator]; - id key; + OFEnumerator *keyEnumerator = [self keyEnumerator]; + OFEnumerator *objectEnumerator = [self objectEnumerator]; + id key, object; uint32_t hash = 0; - while ((key = [enumerator nextObject]) != nil) { + while ((key = [keyEnumerator nextObject]) != nil && + (object = [objectEnumerator nextObject]) != nil) { hash += [key hash]; - hash += [[self objectForKey: key] hash]; + hash += [object hash]; } objc_autoreleasePoolPop(pool); return hash;