@@ -618,10 +618,16 @@ for (i = 0; i < size; i++) if (data[i] != NULL && data[i] != DELETED) [dict setObject: block(data[i]->key, data[i]->object) forKey: data[i]->key]; + /* + * Class swizzle the dictionary to be immutable. We declared the return + * type to be OFDictionary*, so it can't be modified anyway. But not + * swizzling it would create a real copy each time -[copy] is called. + */ + dict->isa = [OFDictionary class]; return dict; } - (OFDictionary*)filteredDictionaryUsingBlock: (of_dictionary_filter_block_t)block @@ -633,10 +639,16 @@ if (data[i] != NULL && data[i] != DELETED) if (block(data[i]->key, data[i]->object)) [dict setObject: data[i]->object forKey: data[i]->key]; + /* + * Class swizzle the dictionary to be immutable. We declared the return + * type to be OFDictionary*, so it can't be modified anyway. But not + * swizzling it would create a real copy each time -[copy] is called. + */ + dict->isa = [OFDictionary class]; return dict; } #endif - (void)dealloc @@ -704,10 +716,16 @@ } [ret appendString: @"}"]; [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; } @end @implementation OFDictionaryEnumerator