示例#1
1
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;
  }
}
示例#2
0
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;
}
示例#3
0
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;
}
示例#4
0
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;
}
示例#5
0
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;
}
示例#6
0
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;
}