@@ -354,10 +354,17 @@ len = [pi length]; [pi removeCharactersFromIndex: len - 1 toIndex: len]; + /* + * Class swizzle the string to be immutable. We pass it as + * OFString*, so it can't be modified anyway. But not swizzling + * it would create a real copy each time -[copy] is called. + */ + pi->isa = [OFString class]; + [delegate parser: self foundProcessingInstructions: pi]; [pool release]; @@ -808,10 +815,17 @@ len = [cdata length]; [cdata removeCharactersFromIndex: len - 2 toIndex: len]; + /* + * Class swizzle the string to be immutable. We pass it as OFString*, so + * it can't be modified anyway. But not swizzling it would create a + * real copy each time -[copy] is called. + */ + cdata->isa = [OFString class]; + #if defined(OF_HAVE_PROPERTIES) && defined(OF_HAVE_BLOCKS) if (CDATAHandler != NULL) CDATAHandler(self, cdata); else #endif @@ -871,10 +885,17 @@ len = [comment length]; [comment removeCharactersFromIndex: len - 2 toIndex: len]; + /* + * Class swizzle the string to be immutable. We pass it as OFString*, so + * it can't be modified anyway. But not swizzling it would create a + * real copy each time -[copy] is called. + */ + comment->isa = [OFString class]; + #if defined(OF_HAVE_PROPERTIES) && defined(OF_HAVE_BLOCKS) if (commentHandler != NULL) commentHandler(self, comment); else #endif