mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 11:30:18 +00:00
backup
This commit is contained in:
parent
b0323bfab5
commit
51047f07a5
@ -62,20 +62,20 @@ py_Name py_namev(c11_sv name) {
|
||||
}
|
||||
|
||||
// generate new index
|
||||
NameBucket* entry = PK_MALLOC(sizeof(NameBucket) + name.size + 1);
|
||||
entry->next = NULL;
|
||||
entry->hash = hash;
|
||||
entry->size = name.size;
|
||||
memcpy(entry->data, name.data, name.size);
|
||||
entry->data[name.size] = '\0';
|
||||
NameBucket* bucket = PK_MALLOC(sizeof(NameBucket) + name.size + 1);
|
||||
bucket->next = NULL;
|
||||
bucket->hash = hash;
|
||||
bucket->size = name.size;
|
||||
memcpy(bucket->data, name.data, name.size);
|
||||
bucket->data[name.size] = '\0';
|
||||
if(p == NULL) {
|
||||
pk_string_table.table[index] = entry;
|
||||
pk_string_table.table[index] = bucket;
|
||||
} else {
|
||||
assert(p->next == NULL);
|
||||
p->next = entry;
|
||||
p->next = bucket;
|
||||
}
|
||||
atomic_store(&pk_string_table.lock, false);
|
||||
return (py_Name)entry;
|
||||
return (py_Name)bucket;
|
||||
}
|
||||
|
||||
c11_sv py_name2sv(py_Name index) {
|
||||
|
@ -55,9 +55,10 @@ bool py_hash(py_Ref val, int64_t* out) {
|
||||
py_TypeInfo* ti = pk__type_info(val->type);
|
||||
do {
|
||||
py_Ref slot_hash = py_getdict(&ti->self, __hash__);
|
||||
if(!slot_hash || py_isnone(slot_hash)) break;
|
||||
if(slot_hash && py_isnone(slot_hash)) break;
|
||||
py_Ref slot_eq = py_getdict(&ti->self, __eq__);
|
||||
if(slot_eq) {
|
||||
if(!slot_hash) break;
|
||||
if(!py_call(slot_hash, 1, val)) return false;
|
||||
if(!py_checkint(py_retval())) return false;
|
||||
*out = py_toint(py_retval());
|
||||
|
Loading…
x
Reference in New Issue
Block a user