TypedValue* APCLocalArray::NvGetStr(const ArrayData* ad, const StringData* key) { auto a = asSharedArray(ad); auto index = a->getIndex(key); if (index == -1) return nullptr; return (TypedValue*)&a->getValueRef(index); }
bool APCLocalArray::IsVectorData(const ArrayData* ad) { auto a = asSharedArray(ad); const auto n = a->size(); for (ssize_t i = 0; i < n; i++) { if (a->getIndex(i) != i) return false; } return true; }
void SharedArray::NvGetKey(const ArrayData* ad, TypedValue* out, ssize_t pos) { auto a = asSharedArray(ad); Variant k = a->m_arr->getKey(pos); TypedValue* tv = k.asTypedValue(); // copy w/out clobbering out->_count. out->m_type = tv->m_type; out->m_data.num = tv->m_data.num; if (tv->m_type != KindOfInt64) out->m_data.pstr->incRefCount(); }
void APCLocalArray::Release(ArrayData* ad) { auto const smap = asSharedArray(ad); smap->~APCLocalArray(); MM().smartFreeSize(smap, sizeof(APCLocalArray)); }
ssize_t APCLocalArray::IterRewind(const ArrayData* ad, ssize_t prev) { assert(prev >= 0 && prev < asSharedArray(ad)->m_size); ssize_t next = prev - 1; return next >= 0 ? next : invalid_index; }
ssize_t APCLocalArray::IterAdvance(const ArrayData* ad, ssize_t prev) { auto a = asSharedArray(ad); return a->iterAdvanceImpl(prev); }
ssize_t APCLocalArray::IterEnd(const ArrayData* ad) { auto a = asSharedArray(ad); auto n = a->m_size; return n > 0 ? ssize_t(n - 1) : invalid_index; }
ssize_t APCLocalArray::IterBegin(const ArrayData* ad) { auto a = asSharedArray(ad); return a->m_size > 0 ? 0 : invalid_index; }
ssize_t SharedArray::IterAdvance(const ArrayData* ad, ssize_t prev) { auto a = asSharedArray(ad); assert(prev >= 0 && prev < a->m_size); ssize_t next = prev + 1; return next < a->m_size ? next : invalid_index; }
TypedValue* APCLocalArray::NvGetInt(const ArrayData* ad, int64_t k) { auto a = asSharedArray(ad); auto index = a->getIndex(k); if (index == -1) return nullptr; return (TypedValue*)&a->getValueRef(index); }
ArrayData *APCLocalArray::Escalate(const ArrayData* ad) { auto smap = asSharedArray(ad); auto ret = smap->loadElems(); assert(!ret->isStatic()); return ret; }
HOT_FUNC void SharedArray::Release(ArrayData* ad) { auto const smap = asSharedArray(ad); smap->~SharedArray(); MM().smartFreeSize(smap, sizeof(SharedArray)); }
SharedVariant* SharedArray::GetSharedVariant(const ArrayData* ad) { auto a = asSharedArray(ad); if (a->m_arr->shouldCache()) return nullptr; return a->m_arr; }
CVarRef SharedArray::GetValueRef(const ArrayData* ad, ssize_t pos) { return asSharedArray(ad)->getValueRef(pos); }
bool APCLocalArray::ExistsStr(const ArrayData* ad, const StringData* k) { auto a = asSharedArray(ad); return a->getIndex(k) != -1; }
bool APCLocalArray::ExistsInt(const ArrayData* ad, int64_t k) { return asSharedArray(ad)->getIndex(k) != -1; }
ArrayData* APCLocalArray::EscalateForSort(ArrayData* ad) { auto a = asSharedArray(ad); auto ret = a->loadElems(); assert(!ret->isStatic()); return ret; }