Index: src/OFArray.m ================================================================== --- src/OFArray.m +++ src/OFArray.m @@ -540,20 +540,26 @@ { return [[[OFArrayEnumerator alloc] initWithArray: self mutationsPtr: NULL] autorelease]; } -#ifdef OF_HAVE_BLOCKS +#if defined(OF_HAVE_BLOCKS) && defined(OF_HAVE_FAST_ENUMERATION) - (void)enumerateObjectsUsingBlock: (of_array_enumeration_block_t)block { - size_t i, count = [self count]; + size_t i = 0; BOOL stop = NO; - for (i = 0; i < count && !stop; i++) - block([self objectAtIndex: i], i, &stop); + for (id object in self) { + block(object, i++, &stop); + + if (stop) + break; + } } +#endif +#ifdef OF_HAVE_BLOCKS - (OFArray*)mappedArrayUsingBlock: (of_array_map_block_t)block { OFArray *ret; size_t count = [self count]; id *tmp = [self allocMemoryForNItems: count Index: src/OFDictionary.m ================================================================== --- src/OFDictionary.m +++ src/OFDictionary.m @@ -385,25 +385,26 @@ { @throw [OFNotImplementedException newWithClass: isa selector: _cmd]; } -#ifdef OF_HAVE_BLOCKS +#if defined(OF_HAVE_BLOCKS) && defined(OF_HAVE_FAST_ENUMERATION) - (void)enumerateKeysAndObjectsUsingBlock: (of_dictionary_enumeration_block_t)block { - OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; - OFEnumerator *enumerator = [self keyEnumerator]; - id key; BOOL stop = NO; - while (!stop && (key = [enumerator nextObject]) != nil) + for (id key in self) { block(key, [self objectForKey: key], &stop); - [pool release]; + 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, Index: src/OFSet.m ================================================================== --- src/OFSet.m +++ src/OFSet.m @@ -360,24 +360,25 @@ [element autorelease]; return element; } -#ifdef OF_HAVE_BLOCKS +#if defined(OF_HAVE_BLOCKS) && defined(OF_HAVE_FAST_ENUMERATION) - (void)enumerateObjectsUsingBlock: (of_set_enumeration_block_t)block { - OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; - OFEnumerator *enumerator = [self objectEnumerator]; - id object; BOOL stop = NO; - while (!stop && (object = [enumerator nextObject]) != nil) + for (id object in self) { block(object, &stop); - [pool release]; + if (stop) + break; + } } +#endif +#ifdef OF_HAVE_BLOCKS - (OFSet*)filteredSetUsingBlock: (of_set_filter_block_t)block { OFMutableSet *ret = [OFMutableSet set]; [self enumerateObjectsUsingBlock: ^ (id object, BOOL *stop) {