void HashCollection::remove(int64_t key) { mutateAndBump(); auto p = findForRemove(key, hash_int64(key)); if (validPos(p)) { erase(p); } }
void ArrayOffsetProfile::update(const ArrayData* ad, int64_t i) { auto h = hash_int64(i); auto const pos = ad->hasMixedLayout() ? MixedArray::asMixed(ad)->find(i, h) : ad->isKeyset() ? SetArray::asSet(ad)->find(i, h) : -1; update(pos, 1); }
void ArrayOffsetProfile::update(const ArrayData* ad, const StringData* sd, bool checkForInt) { auto const pos = [&]() -> int32_t { if (ad->hasMixedLayout()) { auto const a = MixedArray::asMixed(ad); int64_t i; if (checkForInt && ad->convertKey(sd, i, false)) { return !checkHACIntishCast() ? a->find(i, hash_int64(i)) : -1; } return a->find(sd, sd->hash()); } else if (ad->isKeyset()) { return SetArray::asSet(ad)->find(sd, sd->hash()); } else { return -1; } }(); update(pos, 1); }
/* * Creating a single-element mixed array with a integer key. The * value is already incref'd. */ ArrayLval EmptyArray::MakeMixed(int64_t key, TypedValue val) { auto const ad = reqAllocArray(MixedArray::SmallScale); MixedArray::InitSmall(ad, 1/*count*/, 1/*size*/, (key >= 0) ? key + 1 : 0); auto const data = ad->data(); auto const hash = reinterpret_cast<int32_t*>(data + MixedArray::SmallSize); auto const mask = MixedArray::SmallMask; auto h = hash_int64(key); hash[h & mask] = 0; data[0].setIntKey(key, h); auto& lval = data[0].data; lval.m_data = val.m_data; lval.m_type = val.m_type; assert(ad->kind() == ArrayData::kMixedKind); assert(ad->m_size == 1); assert(ad->m_pos == 0); assert(ad->hasExactlyOneRef()); assert(ad->m_scale == MixedArray::SmallScale); assert(ad->m_used == 1); assert(ad->checkInvariants()); return { ad, &tvAsVariant(&lval) }; }
bool test(T x) const { auto h = hash_int64(intptr_t(x)); return bits_.test(h1(h)) & bits_.test(h2(h)); }
void insert(T x) { auto h = hash_int64(intptr_t(x)); bits_.set(h1(h)).set(h2(h)); }