mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 11:30:18 +00:00
Update obj.h
This commit is contained in:
parent
8b368904f4
commit
b9db2ce5fa
@ -106,8 +106,6 @@ struct Py_ : PyObject {
|
|||||||
|
|
||||||
#define PY_BUILTIN_CLASS(name) inline static PyVar _type(VM* vm) { return vm->_tp_##name; }
|
#define PY_BUILTIN_CLASS(name) inline static PyVar _type(VM* vm) { return vm->_tp_##name; }
|
||||||
|
|
||||||
|
|
||||||
// memory pool _tp -> [obj1, obj2, ...]
|
|
||||||
static thread_local emhash8::HashMap<void*, std::vector<int*>> _obj_pool;
|
static thread_local emhash8::HashMap<void*, std::vector<int*>> _obj_pool;
|
||||||
|
|
||||||
namespace pkpy {
|
namespace pkpy {
|
||||||
@ -116,7 +114,7 @@ namespace pkpy {
|
|||||||
inline static void call(int* counter) {
|
inline static void call(int* counter) {
|
||||||
PyObject* obj = (PyObject*)(counter + 1);
|
PyObject* obj = (PyObject*)(counter + 1);
|
||||||
std::vector<int*>& pool = _obj_pool[obj->type_id()];
|
std::vector<int*>& pool = _obj_pool[obj->type_id()];
|
||||||
if(pool.size() > 100){
|
if(pool.size() > 60){
|
||||||
obj->~PyObject();
|
obj->~PyObject();
|
||||||
free(counter);
|
free(counter);
|
||||||
}else{
|
}else{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user