new considered harmful

I'm committing my work on HphpArray in bite-sized pieces for easier review. This piece replaces calls to NEW with a factory method. There are many problems with operator new, starting with the fact that the allocator cannot communicate properly with the constructor.

The newly introduced factory method should return ArrayData but that causes many issues right now, so I left that step to a future diff.
Esse commit está contido em:
Andrei Alexandrescu
2013-05-15 20:17:44 -07:00
commit de Sara Golemon
commit 2baabea1ae
19 arquivos alterados com 49 adições e 35 exclusões
+4 -4
Ver Arquivo
@@ -154,8 +154,8 @@ HphpArray::HphpArray(EmptyMode) : ArrayData(kHphpArray),
}
// Empty constructor for internal use by nonSmartCopy() and copyImpl()
HphpArray::HphpArray(CopyMode mode) :
ArrayData(kHphpArray, /*nonsmart*/ mode == kNonSmartCopy) {
HphpArray::HphpArray(AllocationPolicy mode) :
ArrayData(kHphpArray, /*nonsmart*/ mode == AllocationPolicy::nonSmart) {
}
HOT_FUNC_VM
@@ -1446,11 +1446,11 @@ inline ALWAYS_INLINE HphpArray* HphpArray::copyImpl(HphpArray* target) const {
}
NEVER_INLINE ArrayData* HphpArray::nonSmartCopy() const {
return copyImpl(new HphpArray(kNonSmartCopy));
return copyImpl(new HphpArray(AllocationPolicy::nonSmart));
}
NEVER_INLINE HphpArray* HphpArray::copyImpl() const {
return copyImpl(NEW(HphpArray)(kSmartCopy));
return copyImpl(NEW(HphpArray)(AllocationPolicy::smart));
}
ArrayData* HphpArray::append(CVarRef v, bool copy) {