void SharedVariant::loadElems(ArrayData *&elems, const SharedMap &sharedMap, bool keepRef /* = false */) { ASSERT(is(KindOfArray)); uint count = arrSize(); ArrayInit ai(count, getIsVector(), keepRef); for (uint i = 0; i < count; i++) { if (getIsVector()) { ai.add((int64)i, sharedMap.getValueRef(i), true); } else { ai.add(m_data.map->getKeyIndex(i)->toLocal(), sharedMap.getValueRef(i), true); } } elems = ai.create(); if (elems->isStatic()) elems = elems->copy(); }
void SharedVariant::loadElems(ArrayData *&elems, const SharedMap &sharedMap, bool keepRef /* = false */, bool mapInit /* = false */) { assert(is(KindOfArray)); uint count = arrSize(); bool isVector = getIsVector(); ArrayInit ai = keepRef ? ArrayInit(count, true) : mapInit ? ArrayInit(count, ArrayInit::mapInit) : isVector ? ArrayInit(count, ArrayInit::vectorInit) : ArrayInit(count, false); if (isVector) { for (uint i = 0; i < count; i++) { ai.set(sharedMap.getValueRef(i)); } } else { for (uint i = 0; i < count; i++) { ai.add(m_data.map->getKeyIndex(i)->toLocal(), sharedMap.getValueRef(i), true); } } elems = ai.create(); if (elems->isStatic()) elems = elems->copy(); }