Index: src/OFString.m ================================================================== --- src/OFString.m +++ src/OFString.m @@ -2045,19 +2045,22 @@ return new; } - (OFString *)stringByAppendingPathComponent: (OFString *)component { - void *pool = objc_autoreleasePoolPush(); - OFString *ret; - - ret = [OFString pathWithComponents: - [OFArray arrayWithObjects: self, component, nil]]; - - [ret retain]; - objc_autoreleasePoolPop(pool); - return [ret autorelease]; + if ([self hasSuffix: OF_PATH_DELIMITER_STRING]) + return [self stringByAppendingString: component]; + else { + OFMutableString *ret = [[self mutableCopy] autorelease]; + + [ret appendString: OF_PATH_DELIMITER_STRING]; + [ret appendString: component]; + + [ret makeImmutable]; + + return ret; + } } - (OFString *)stringByPrependingString: (OFString *)string { OFMutableString *new = [[string mutableCopy] autorelease]; Index: tests/OFStringTests.m ================================================================== --- tests/OFStringTests.m +++ tests/OFStringTests.m @@ -548,10 +548,21 @@ [[C(@"foo") stringByAppendingString: @"bar"] isEqual: @"foobar"]) TEST(@"-[stringByPrependingString:]", [[C(@"foo") stringByPrependingString: @"bar"] isEqual: @"barfoo"]) + s[0] = [mutableStringClass stringWithString: @"foo"]; + [s[0] appendString: OF_PATH_DELIMITER_STRING]; + [s[0] appendString: @"bar"]; + s[1] = [mutableStringClass stringWithString: s[0]]; + [s[1] appendString: OF_PATH_DELIMITER_STRING]; + is = [stringClass stringWithString: s[1]]; + [s[1] appendString: @"baz"]; + TEST(@"-[stringByAppendingPathComponent:]", + [[s[0] stringByAppendingPathComponent: @"baz"] isEqual: s[1]] && + [[is stringByAppendingPathComponent: @"baz"] isEqual: s[1]]) + TEST(@"-[hasPrefix:]", [C(@"foobar") hasPrefix: @"foo"] && ![C(@"foobar") hasPrefix: @"foobar0"]) TEST(@"-[hasSuffix:]", [C(@"foobar") hasSuffix: @"bar"] && ![C(@"foobar") hasSuffix: @"foobar0"])