diff options
author | Guido van Rossum <guido@python.org> | 1997-02-14 16:29:22 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1997-02-14 16:29:22 (GMT) |
commit | 36b9f7908a168957d151595817b2c06a2fcb9a40 (patch) | |
tree | 9ef15fb56227b1c7d54c63043a6d42ce282f57d3 /Objects/stringobject.c | |
parent | 7582bfb60a7027b57d79c44a5e8531a31d1a8f2a (diff) | |
download | cpython-36b9f7908a168957d151595817b2c06a2fcb9a40.zip cpython-36b9f7908a168957d151595817b2c06a2fcb9a40.tar.gz cpython-36b9f7908a168957d151595817b2c06a2fcb9a40.tar.bz2 |
Slight tweak: in string_hash(), if the hash hasn't been computed yet,
and if there's a pointer to an interned version of the string, use its
hash and store its hash in this object, rather than recomputing it.
Diffstat (limited to 'Objects/stringobject.c')
-rw-r--r-- | Objects/stringobject.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/Objects/stringobject.c b/Objects/stringobject.c index 283e219..724121f 100644 --- a/Objects/stringobject.c +++ b/Objects/stringobject.c @@ -433,6 +433,11 @@ string_hash(a) #ifdef CACHE_HASH if (a->ob_shash != -1) return a->ob_shash; +#ifdef INTERN_STRINGS + if (a->ob_sinterned != NULL) + return (a->ob_shash = + ((stringobject *)(a->ob_sinterned))->ob_shash); +#endif #endif len = a->ob_size; p = (unsigned char *) a->ob_sval; |