@@ -160,10 +160,16 @@ @throw [OFInvalidEncodingException newWithClass: isa]; [ret appendCStringWithoutUTF8Checking: string + last length: i - last]; + /* + * 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; } #ifdef OF_HAVE_BLOCKS - (OFString*)stringByXMLUnescapingWithBlock: @@ -244,9 +250,15 @@ @throw [OFInvalidEncodingException newWithClass: isa]; [ret appendCStringWithoutUTF8Checking: string + last length: i - last]; + /* + * 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; } #endif @end