summaryrefslogtreecommitdiffstats
path: root/Objects/unicodeobject.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2007-09-18 04:30:42 (GMT)
committerGuido van Rossum <guido@python.org>2007-09-18 04:30:42 (GMT)
commit4d0277233e184dabefdbc966f5764034737cd2b9 (patch)
tree54dd9da427bd7569bdb61fab373ac68c0736dfe6 /Objects/unicodeobject.c
parent54cf12b625397ff52e30efd9b14f0b61edfdfd9d (diff)
downloadcpython-4d0277233e184dabefdbc966f5764034737cd2b9.zip
cpython-4d0277233e184dabefdbc966f5764034737cd2b9.tar.gz
cpython-4d0277233e184dabefdbc966f5764034737cd2b9.tar.bz2
Micro optimizations after staring at gprof output for a while.
Diffstat (limited to 'Objects/unicodeobject.c')
-rw-r--r--Objects/unicodeobject.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index d52c080..140ffaf 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -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);
}
}