hphp/runtime/base/packed-array.cpp
/*
 * Converts a packed array to mixed, leaving the packed array in an
 * empty state.  You need ToMixedCopy in cases where the old array
 * needs to remain un-modified (usually if `copy' is true).
 *
 * The returned array is mixed, and is guaranteed not to be isFull().
 * (Note: only unset can call ToMixed when we aren't about to insert.)
 */
Converts a packed array to mixed, leaving the packed array in an
empty state.  You need ToMixedCopy in cases where the old array
needs to remain un-modified (usually if `copy' is true).

The returned array is mixed, and is guaranteed not to be isFull().
(Note: only unset can call ToMixed when we aren't about to insert.)
Converts a packed array to mixed leaving the packed array in an empty state . You need ToMixedCopy in cases where the old array needs to remain un - modified ( usually if ` copy ' is true ) . The returned array is mixed and is guaranteed not to be isFull () . ( Note : only unset can call ToMixed when we aren ' t about to insert . )
MixedArray* PackedArray::ToMixed(ArrayData* old) {
  auto const oldSize = old->m_size;
  auto const ad      = ToMixedHeader(old, oldSize + 1);
  auto const mask    = ad->mask();
  auto dstData       = ad->data();
  auto const dstHash = ad->initHash(ad->scale());
  for (uint32_t i = 0; i < oldSize; ++i) {
    auto h = hash_int64(i);
    *ad->findForNewInsert(dstHash, mask, h) = i;
    dstData->setIntKey(i, h);
    tvCopy(GetPosVal(old, i), dstData->data);
    ++dstData;
  }
  old->m_size = 0;
  assertx(ad->checkInvariants());
  assertx(!ad->isFull());
  assertx(ad->hasExactlyOneRef());
  return ad;
}
MixedArray * PackedArray :: ToMixed ( ArrayData * old ) { auto const oldSize = old -> m_size ; auto const ad = ToMixedHeader ( old , oldSize + 1 ) ; auto const mask = ad -> mask ( ) ; auto dstData = ad -> data ( ) ; auto const dstHash = ad -> initHash ( ad -> scale ( ) ) ; for ( uint32_t i = 0 ; i < oldSize ; ++ i ) { auto h = hash_int64 ( i ) ; * ad -> findForNewInsert ( dstHash , mask , h ) = i ; dstData -> setIntKey ( i , h ) ; tvCopy ( GetPosVal ( old , i ) , dstData -> data ) ; ++ dstData ; } old -> m_size = 0 ; assertx ( ad -> checkInvariants ( ) ) ; assertx ( ! ad -> isFull ( ) ) ; assertx ( ad -> hasExactlyOneRef ( ) ) ; return ad ; }
Converts a packed array to mixed, leaving the packed array in an
 empty state.
Converts a packed array to mixed leaving the packed array in an empty state .