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:
commit de
Sara Golemon
pai
7fbef94637
commit
2baabea1ae
@@ -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) {
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário