mirror of
https://github.com/Decompollaborate/rabbitizer.git
synced 2025-02-15 12:41:27 +00:00
Use proper hash function
This commit is contained in:
parent
eb407ec9d3
commit
ed678cfeb6
@ -91,15 +91,21 @@ static PyGetSetDef rabbitizer_type_Enum_getsetters[] = {
|
||||
};
|
||||
|
||||
|
||||
// Crappy hash
|
||||
Py_hash_t rabbitizer_type_Enum_hash(PyRabbitizerEnum *self) {
|
||||
Py_hash_t hash = PyObject_Hash(self->enumType);
|
||||
PyObject *tuple = PyTuple_Pack(2, self->enumType, PyLong_FromLong(self->value));
|
||||
Py_hash_t hash;
|
||||
|
||||
if (tuple == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
hash = PyObject_Hash(tuple);
|
||||
|
||||
if (hash == -1) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return hash + self->value;
|
||||
return hash;
|
||||
}
|
||||
|
||||
// Checks for the 6 basic comparisons (==, !=, <, <=, >, >=)
|
||||
|
Loading…
x
Reference in New Issue
Block a user