Change copy-on-write protocol to always return valid pointers

Streamline the array access methods by always returning an array
pointer instead of a new pointer or null.  Callsites compare
(new != old) to detect escalation, rather than (new != null).
Esse commit está contido em:
smith
2013-03-29 12:24:43 -07:00
commit de Sara Golemon
commit cc0ef7c456
12 arquivos alterados com 255 adições e 453 exclusões
+3 -8
Ver Arquivo
@@ -223,7 +223,7 @@ ArrayData *ArrayData::pop(Variant &value) {
return remove(getKey(pos), getCount() > 1);
}
value = uninit_null();
return nullptr;
return this;
}
ArrayData *ArrayData::dequeue(Variant &value) {
@@ -233,16 +233,11 @@ ArrayData *ArrayData::dequeue(Variant &value) {
ArrayData *ret = remove(getKey(pos), getCount() > 1);
// In PHP, array_shift() will cause all numerically key-ed values re-keyed
if (ret) {
ret->renumber();
} else {
renumber();
}
ret->renumber();
return ret;
}
value = uninit_null();
return nullptr;
return this;
}
///////////////////////////////////////////////////////////////////////////////