summaryrefslogtreecommitdiffstats
path: root/Objects/dictobject.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/dictobject.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/dictobject.c')
-rw-r--r--Objects/dictobject.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/Objects/dictobject.c b/Objects/dictobject.c
index 539d734..96089a1 100644
--- a/Objects/dictobject.c
+++ b/Objects/dictobject.c
@@ -566,8 +566,8 @@ PyDict_GetItem(PyObject *op, PyObject *key)
PyThreadState *tstate;
if (!PyDict_Check(op))
return NULL;
- if (!PyString_CheckExact(key) ||
- (hash = ((PyStringObject *) key)->ob_shash) == -1)
+ if (!PyUnicode_CheckExact(key) ||
+ (hash = ((PyUnicodeObject *) key)->hash) == -1)
{
hash = PyObject_Hash(key);
if (hash == -1) {
@@ -650,12 +650,9 @@ PyDict_SetItem(register PyObject *op, PyObject *key, PyObject *value)
assert(key);
assert(value);
mp = (dictobject *)op;
- if (PyString_CheckExact(key)) {
- hash = ((PyStringObject *)key)->ob_shash;
- if (hash == -1)
- hash = PyObject_Hash(key);
- }
- else {
+ if (!PyUnicode_CheckExact(key) ||
+ (hash = ((PyUnicodeObject *) key)->hash) == -1)
+ {
hash = PyObject_Hash(key);
if (hash == -1)
return -1;