@@ -1422,106 +1422,78 @@ OFMutableString *new; new = [OFMutableString stringWithString: self]; [new appendString: string]; - /* - * 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. - */ - new->isa = [OFString class]; + [new makeImmutable]; + return new; } - (OFString*)stringByPrependingString: (OFString*)string { OFMutableString *new = [[string mutableCopy] autorelease]; [new appendString: self]; - /* - * 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. - */ - new->isa = [OFString class]; + [new makeImmutable]; + return new; } - (OFString*)uppercaseString { OFMutableString *new = [[self mutableCopy] autorelease]; [new upper]; - /* - * 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. - */ - new->isa = [OFString class]; + [new makeImmutable]; + return new; } - (OFString*)lowercaseString { OFMutableString *new = [[self mutableCopy] autorelease]; [new lower]; - /* - * 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. - */ - new->isa = [OFString class]; + [new makeImmutable]; + return new; } - (OFString*)stringByDeletingLeadingWhitespaces { OFMutableString *new = [[self mutableCopy] autorelease]; [new deleteLeadingWhitespaces]; - /* - * 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. - */ - new->isa = [OFString class]; + [new makeImmutable]; + return new; } - (OFString*)stringByDeletingTrailingWhitespaces { OFMutableString *new = [[self mutableCopy] autorelease]; [new deleteTrailingWhitespaces]; - /* - * 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. - */ - new->isa = [OFString class]; + [new makeImmutable]; + return new; } - (OFString*)stringByDeletingEnclosingWhitespaces { OFMutableString *new = [[self mutableCopy] autorelease]; [new deleteEnclosingWhitespaces]; - /* - * 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. - */ - new->isa = [OFString class]; + [new makeImmutable]; + return new; } - (BOOL)hasPrefix: (OFString*)prefix { @@ -1571,13 +1543,15 @@ i += cStringLength - 1; last = i + 1; } [array addObject: [OFString stringWithCString: s->cString + last]]; + [array makeImmutable]; + [pool release]; - return [array makeImmutable]; + return array; } - (OFArray*)pathComponents { OFMutableArray *ret; @@ -1613,13 +1587,15 @@ } [ret addObject: [OFString stringWithCString: s->cString + last length: i - last]]; + [ret makeImmutable]; + [pool release]; - return [ret makeImmutable]; + return ret; } - (OFString*)lastPathComponent { size_t pathCStringLength = s->cStringLength;