Micro optimizations after staring at gprof output for a while.

This commit is contained in:
Guido van Rossum 2007-09-18 04:30:42 +00:00
parent 54cf12b625
commit 4d0277233e
2 changed files with 9 additions and 11 deletions

View file

@ -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);
}
}