ArrayData* EmptyArray::ZAppend(ArrayData* ad, RefData* v, int64_t* key_ptr) { auto const arr = MixedArray::MakeReserveMixed(MixedArray::SmallSize); arr->setRefCount(0); DEBUG_ONLY auto const tmp = arr->zAppend(v, key_ptr); assert(tmp == arr); return arr; }
ArrayData* EmptyArray::ZSetStr(ArrayData* ad, StringData* k, RefData* v) { auto const arr = MixedArray::MakeReserveMixed(MixedArray::SmallSize); arr->setRefCount(0); DEBUG_ONLY auto const tmp = arr->zSet(k, v); assert(tmp == arr); return arr; }
void VariableSerializer::write(CVarRef v, bool isArrayKey /* = false */) { if (!isArrayKey && v.isObject()) { write(v.toObject()); return; } setReferenced(v.isReferenced()); setRefCount(v.getRefCount()); v.serialize(this, isArrayKey); }
Zerberus::~Zerberus() { busy = true; while (!instruments.empty()) { auto i = instruments.front(); auto it = instruments.begin(); instruments.erase(it); i->setRefCount(i->refCount() - 1); if (i->refCount() <= 0) { delete i; auto it = find(globalInstruments.begin(), globalInstruments.end(), i); if (it != globalInstruments.end()) globalInstruments.erase(it); } } }
/** * concat_si will incRef the output string * and decref its first argument */ StringData* concat_si(StringData* v1, int64_t v2) { char intbuf[21]; auto const s2 = conv_10(v2, intbuf + sizeof(intbuf)); if (v1->hasMultipleRefs()) { auto const s1 = v1->slice(); auto const ret = StringData::Make(s1, s2); ret->setRefCount(1); // Because v1->getCount() is greater than 1, we know we will never // have to release the string here v1->decRefCount(); return ret; } auto const ret = v1->append(s2); if (UNLIKELY(ret != v1)) { assert(v1->hasExactlyOneRef()); v1->release(); ret->incRefCount(); } return ret; }
void StringData::setUncounted() { setRefCount(UncountedValue); preCompute(); }
void StringData::setStatic() { setRefCount(StaticValue); preCompute(); }