diff Objects/stringobject.c @ 5098:a44586bd9fab legacy-trunk

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.
author Guido van Rossum <guido@python.org>
date Fri, 14 Feb 1997 16:29:22 +0000
parents 6c7a76fd5dc1
children 0f1711b7d367
line wrap: on
line diff
--- a/Objects/stringobject.c	Fri Feb 14 16:27:29 1997 +0000
+++ b/Objects/stringobject.c	Fri Feb 14 16:29:22 1997 +0000
@@ -433,6 +433,11 @@
 #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;