Index: src/OFArray.m ================================================================== --- src/OFArray.m +++ src/OFArray.m @@ -434,11 +434,10 @@ { OFAutoreleasePool *pool; OFMutableString *ret; OFObject **cArray; size_t i, count; - IMP append; if ([array count] == 0) { if ([self isKindOfClass: [OFMutableArray class]]) return @"()"; else @@ -451,16 +450,14 @@ ret = [OFMutableString stringWithFormat: @"(\n", count]; else ret = [OFMutableString stringWithFormat: @"<%zd>(\n", count]; pool = [[OFAutoreleasePool alloc] init]; - append = [ret methodForSelector: @selector(appendString:)]; for (i = 0; i < count - 1; i++) { - append(ret, @selector(appendString:), - [cArray[i] stringBySerializing]); - append(ret, @selector(appendString:), @",\n"); + [ret appendString: [cArray[i] stringBySerializing]]; + [ret appendString: @",\n"]; [pool releaseObjects]; } [ret replaceOccurrencesOfString: @"\n" withString: @"\n\t"]; Index: src/OFList.h ================================================================== --- src/OFList.h +++ src/OFList.h @@ -15,10 +15,11 @@ */ #import "OFObject.h" #import "OFCollection.h" #import "OFEnumerator.h" +#import "OFSerialization.h" typedef struct of_list_object_t of_list_object_t; /** * \brief A list object. * @@ -35,11 +36,12 @@ }; /** * \brief A class which provides easy to use double-linked lists. */ -@interface OFList: OFObject +@interface OFList: OFObject { of_list_object_t *firstListObject; of_list_object_t *lastListObject; size_t count; unsigned long mutations; Index: src/OFList.m ================================================================== --- src/OFList.m +++ src/OFList.m @@ -306,15 +306,49 @@ if (iter->next != NULL) [ret appendString: @",\n"]; [pool releaseObjects]; } - [ret replaceOccurrencesOfString: @"\n" withString: @"\n\t"]; [ret appendString: @"\n]"]; + [pool release]; + + /* + * Class swizzle the string to be immutable. We declared the return type + * to be OFString*, so it can't be modified anyway. But not swizzling it + * would create a real copy each time -[copy] is called. + */ + ret->isa = [OFString class]; + return ret; +} + +- (OFString*)stringBySerializing +{ + OFMutableString *ret; + OFAutoreleasePool *pool; + of_list_object_t *iter; + + if (count == 0) + return @"()"; + + ret = [OFMutableString stringWithString: @"(\n"]; + pool = [[OFAutoreleasePool alloc] init]; + + for (iter = firstListObject; iter != NULL; iter = iter->next) { + [ret appendString: [iter->object stringBySerializing]]; + + if (iter->next != NULL) + [ret appendString: @",\n"]; + + [pool releaseObjects]; + } + [ret replaceOccurrencesOfString: @"\n" + withString: @"\n\t"]; + [ret appendString: @"\n)"]; + [pool release]; /* * Class swizzle the string to be immutable. We declared the return type * to be OFString*, so it can't be modified anyway. But not swizzling it