mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-22 04:20:17 +00:00
improve performance
This commit is contained in:
parent
bd36a53226
commit
7b4994ee35
@ -40,6 +40,6 @@ py_TypeInfo* TypeList__get(TypeList* self, py_Type index);
|
||||
py_TypeInfo* TypeList__emplace(TypeList* self);
|
||||
void TypeList__apply(TypeList* self, void (*f)(py_TypeInfo*, void*), void* ctx);
|
||||
py_TValue* TypeList__magic(py_TypeInfo* self, unsigned index);
|
||||
py_TValue* TypeList__magic_readonly_nullable(py_TypeInfo* self, unsigned index);
|
||||
py_TValue* TypeList__magic_readonly(py_TypeInfo* self, unsigned index);
|
||||
|
||||
#define TypeList__magic_common(ti, index) ((ti)->magic_0 + ((index)-PK_MAGIC_SLOTS_UNCOMMON_LENGTH))
|
||||
|
@ -60,18 +60,14 @@ py_TValue* TypeList__magic(py_TypeInfo* self, unsigned index) {
|
||||
return self->magic_1 + index;
|
||||
}
|
||||
|
||||
py_TValue* TypeList__magic_readonly_nullable(py_TypeInfo* self, unsigned index) {
|
||||
py_TValue* TypeList__magic_readonly(py_TypeInfo* self, unsigned index) {
|
||||
if(index > __xor__) {
|
||||
// common magic slots
|
||||
py_TValue* slot = TypeList__magic_common(self, index);
|
||||
if(py_isnil(slot)) return NULL;
|
||||
return slot;
|
||||
return TypeList__magic_common(self, index);
|
||||
}
|
||||
// uncommon magic slots
|
||||
if(self->magic_1 == NULL) return NULL;
|
||||
py_TValue* slot = self->magic_1 + index;
|
||||
if(py_isnil(slot)) return NULL;
|
||||
return slot;
|
||||
if(self->magic_1 == NULL) return py_NIL();
|
||||
return self->magic_1 + index;
|
||||
}
|
||||
|
||||
#undef CHUNK_SIZE
|
||||
|
@ -227,8 +227,9 @@ py_Ref py_tpfindmagic(py_Type t, py_Name name) {
|
||||
assert(py_ismagicname(name));
|
||||
py_TypeInfo* ti = pk__type_info(t);
|
||||
do {
|
||||
py_Ref f = TypeList__magic_readonly_nullable(ti, name);
|
||||
if(f != NULL) return f;
|
||||
py_Ref f = TypeList__magic_readonly(ti, name);
|
||||
assert(f != NULL);
|
||||
if(!py_isnil(f)) return f;
|
||||
ti = ti->base_ti;
|
||||
} while(ti);
|
||||
return NULL;
|
||||
|
Loading…
x
Reference in New Issue
Block a user