inline ~PyObject

This commit is contained in:
blueloveTH 2024-03-03 01:32:34 +08:00
parent 3edd4aca67
commit 206685a3f6
2 changed files with 5 additions and 7 deletions

View File

@ -111,7 +111,11 @@ struct PyObject{
PyObject(Type type) : gc_enabled(true), gc_marked(false), type(type), _attr(nullptr) {}
virtual ~PyObject();
virtual ~PyObject(){
if(_attr == nullptr) return;
_attr->~NameDict();
pool128_dealloc(_attr);
}
void _enable_instance_dict() {
_attr = new(pool128_alloc<NameDict>()) NameDict();

View File

@ -1,12 +1,6 @@
#include "pocketpy/obj.h"
namespace pkpy{
PyObject::~PyObject() {
if(_attr == nullptr) return;
_attr->~NameDict();
pool128_dealloc(_attr);
}
bool Bytes::operator==(const Bytes& rhs) const{
if(_size != rhs._size) return false;
for(int i=0; i<_size; i++) if(_data[i] != rhs._data[i]) return false;