Esempio n. 1
0
HOT_FUNC
CVarRef SharedMap::getValueRef(ssize_t pos) const {
  SharedVariant *sv = getValueImpl(pos);
  DataType t = sv->getType();
  if (!IS_REFCOUNTED_TYPE(t)) return sv->asCVarRef();
  if (LIKELY(m_localCache != nullptr)) {
    assert(unsigned(pos) < size());
    TypedValue* tv = &m_localCache[pos];
    if (tv->m_type != KindOfUninit) return tvAsCVarRef(tv);
  } else {
    static_assert(KindOfUninit == 0, "must be 0 since we use smart_calloc");
    m_localCache = (TypedValue*) smart_calloc(size(), sizeof(TypedValue));
  }
  TypedValue* tv = &m_localCache[pos];
  tvAsVariant(tv) = sv->toLocal();
  assert(tv->m_type != KindOfUninit);
  return tvAsCVarRef(tv);
}
Esempio n. 2
0
HOT_FUNC
CVarRef SharedMap::getValueRef(ssize_t pos) const {
    SharedVariant *sv = m_arr->getValue(pos);
    DataType t = sv->getType();
    if (!IS_REFCOUNTED_TYPE(t)) return sv->asCVarRef();
    if (LIKELY(m_localCache != NULL)) {
        Variant *pv;
        ArrayData *escalated DEBUG_ONLY =
            m_localCache->ZendArray::lvalPtr((int64)pos, pv, false, false);
        assert(!escalated);
        if (pv) return *pv;
    } else {
        m_localCache = NEW(ZendArray)();
        m_localCache->incRefCount();
    }
    Variant v = sv->toLocal();
    Variant *r;
    ArrayData *escalated DEBUG_ONLY =
        m_localCache->ZendArray::addLval((int64)pos, r, false);
    assert(!escalated);
    *r = v;
    return *r;
}