Chromium Code Reviews| Index: src/objects.cc |
| diff --git a/src/objects.cc b/src/objects.cc |
| index 1f25a5d11b7dcd788a6541e41781eb98e826f6b7..ed394ad0ca8c79c75cd6f964c151e111afaef537 100644 |
| --- a/src/objects.cc |
| +++ b/src/objects.cc |
| @@ -7856,28 +7856,22 @@ Handle<WeakFixedArray> WeakFixedArray::Allocate( |
| DCHECK(0 <= size); |
| Handle<FixedArray> result = |
| isolate->factory()->NewUninitializedFixedArray(size + kFirstIndex); |
| - Handle<WeakFixedArray> casted_result = Handle<WeakFixedArray>::cast(result); |
| - if (initialize_from.is_null()) { |
| - for (int i = 0; i < result->length(); ++i) { |
| - result->set(i, Smi::FromInt(0)); |
| - } |
| - } else { |
| + int index = 0; |
| + if (!initialize_from.is_null()) { |
| DCHECK(initialize_from->Length() <= size); |
| Handle<FixedArray> raw_source = Handle<FixedArray>::cast(initialize_from); |
| - int target_index = kFirstIndex; |
| - for (int source_index = kFirstIndex; source_index < raw_source->length(); |
| - ++source_index) { |
| - // The act of allocating might have caused entries in the source array |
| - // to be cleared. Copy only what's needed. |
| - if (initialize_from->IsEmptySlot(source_index - kFirstIndex)) continue; |
| - result->set(target_index++, raw_source->get(source_index)); |
| - } |
| - casted_result->set_last_used_index(target_index - 1 - kFirstIndex); |
| - for (; target_index < result->length(); ++target_index) { |
| - result->set(target_index, Smi::FromInt(0)); |
| + // Copy the entries without compacting, since the PrototypeInfo relies on |
| + // the index of the entries not to change. |
| + while (index < raw_source->length()) { |
| + result->set(index, raw_source->get(index)); |
| + index++; |
| } |
|
mvstanton
2015/08/19 13:52:12
How about calling set_last_used_index(index); here
|
| } |
| - return casted_result; |
| + while (index < result->length()) { |
| + result->set(index, Smi::FromInt(0)); |
| + index++; |
| + } |
| + return Handle<WeakFixedArray>::cast(result); |
| } |