# File activerecord/lib/active_record/associations/collection_association.rb, line 398def merge_target_lists(persisted,memory)returnpersistedifmemory.empty?returnmemoryifpersisted.empty?persisted.map!do|record|# Unfortunately we cannot simply do memory.delete(record) since on 1.8 this returns# record rather than memory.at(memory.index(record)). The behavior is fixed in 1.9.mem_index=memory.index(record)ifmem_indexmem_record=memory.delete_at(mem_index)(record.attribute_names-mem_record.changes.keys).eachdo|name|mem_record[name]=record[name]endmem_recordelserecordendendpersisted+memoryend