ArrayData *ZendArray::remove(CVarRef k, bool copy) { TypedValueAccessor tva = k.getTypedAccessor(); if (isIntKey(tva)) { if (UNLIKELY(copy)) { ZendArray *a = copyImpl(); a->prepareBucketHeadsForWrite(); a->erase(a->findForErase(getIntKey(tva))); return a; } prepareBucketHeadsForWrite(); erase(findForErase(getIntKey(tva))); return NULL; } else { ASSERT(k.isString()); StringData *key = getStringKey(tva); int64 prehash = key->hash(); if (UNLIKELY(copy)) { ZendArray *a = copyImpl(); a->prepareBucketHeadsForWrite(); a->erase(a->findForErase(key->data(), key->size(), prehash)); return a; } prepareBucketHeadsForWrite(); erase(findForErase(key->data(), key->size(), prehash)); return NULL; } }
ArrayData *ZendArray::remove(CStrRef k, bool copy) { int64 prehash = k->hash(); if (UNLIKELY(copy)) { ZendArray *a = copyImpl(); a->erase(a->findForErase(k.data(), k.size(), prehash)); return a; } erase(findForErase(k.data(), k.size(), prehash)); return NULL; }
HOT_FUNC_HPHP ArrayData *ZendArray::remove(int64 k, bool copy) { if (UNLIKELY(copy)) { ZendArray *a = copyImpl(); a->erase(a->findForErase(k)); return a; } erase(findForErase(k)); return NULL; }
ArrayData *ZendArray::remove(int64 k, bool copy) { if (UNLIKELY(copy)) { ZendArray *a = copyImpl(); a->prepareBucketHeadsForWrite(); a->erase(a->findForErase(k)); return a; } prepareBucketHeadsForWrite(); erase(findForErase(k)); return NULL; }
ArrayData *ZendArray::pop(Variant &value) { if (getCount() > 1) { ZendArray *a = copyImpl(); a->pop(value); return a; } if (m_pListTail) { value = m_pListTail->data; erase(findForErase(m_pListTail), true); } else { value = null; } // To match PHP-like semantics, the pop operation resets the array's // internal iterator m_pos = (ssize_t)m_pListHead; return NULL; }
ArrayData *ZendArray::dequeue(Variant &value) { if (getCount() > 1) { ZendArray *a = copyImpl(); a->dequeue(value); return a; } // To match PHP-like semantics, we invalidate all strong iterators // when an element is removed from the beginning of the array if (!m_strongIterators.empty()) { freeStrongIterators(); } if (m_pListHead) { value = m_pListHead->data; erase(findForErase(m_pListHead)); renumber(); } else { value = null; } // To match PHP-like semantics, the dequeue operation resets the array's // internal iterator m_pos = (ssize_t)m_pListHead; return NULL; }