mirror of
https://github.com/python/cpython.git
synced 2025-07-16 07:45:20 +00:00
Micro optimizations after staring at gprof output for a while.
This commit is contained in:
parent
54cf12b625
commit
4d0277233e
2 changed files with 9 additions and 11 deletions
|
@ -6597,9 +6597,10 @@ unicode_hash(PyUnicodeObject *self)
|
|||
/* Since Unicode objects compare equal to their UTF-8 string
|
||||
counterparts, we hash the UTF-8 string. */
|
||||
PyObject *v = _PyUnicode_AsDefaultEncodedString((PyObject*)self, NULL);
|
||||
long x = PyObject_Hash(v);
|
||||
self->hash = x;
|
||||
return x;
|
||||
if (v == NULL)
|
||||
return -1;
|
||||
assert(PyString_CheckExact(v));
|
||||
return self->hash = v->ob_type->tp_hash(v);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue