@@ -72,12 +72,8 @@ PyString_FromStringAndSize(const char *str, int size)
7272 if (op == NULL )
7373 return PyErr_NoMemory ();
7474 PyObject_INIT_VAR (op , & PyString_Type , size );
75- #ifdef CACHE_HASH
7675 op -> ob_shash = -1 ;
77- #endif
78- #ifdef INTERN_STRINGS
7976 op -> ob_sinterned = NULL ;
80- #endif
8177 if (str != NULL )
8278 memcpy (op -> ob_sval , str , size );
8379 op -> ob_sval [size ] = '\0' ;
@@ -135,12 +131,8 @@ PyString_FromString(const char *str)
135131 if (op == NULL )
136132 return PyErr_NoMemory ();
137133 PyObject_INIT_VAR (op , & PyString_Type , size );
138- #ifdef CACHE_HASH
139134 op -> ob_shash = -1 ;
140- #endif
141- #ifdef INTERN_STRINGS
142135 op -> ob_sinterned = NULL ;
143- #endif
144136 memcpy (op -> ob_sval , str , size + 1 );
145137#ifndef DONT_SHARE_SHORT_STRINGS
146138 if (size == 0 ) {
@@ -737,12 +729,8 @@ string_concat(register PyStringObject *a, register PyObject *bb)
737729 if (op == NULL )
738730 return PyErr_NoMemory ();
739731 PyObject_INIT_VAR (op , & PyString_Type , size );
740- #ifdef CACHE_HASH
741732 op -> ob_shash = -1 ;
742- #endif
743- #ifdef INTERN_STRINGS
744733 op -> ob_sinterned = NULL ;
745- #endif
746734 memcpy (op -> ob_sval , a -> ob_sval , (int ) a -> ob_size );
747735 memcpy (op -> ob_sval + a -> ob_size , b -> ob_sval , (int ) b -> ob_size );
748736 op -> ob_sval [size ] = '\0' ;
@@ -784,12 +772,8 @@ string_repeat(register PyStringObject *a, register int n)
784772 if (op == NULL )
785773 return PyErr_NoMemory ();
786774 PyObject_INIT_VAR (op , & PyString_Type , size );
787- #ifdef CACHE_HASH
788775 op -> ob_shash = -1 ;
789- #endif
790- #ifdef INTERN_STRINGS
791776 op -> ob_sinterned = NULL ;
792- #endif
793777 for (i = 0 ; i < size ; i += a -> ob_size )
794778 memcpy (op -> ob_sval + i , a -> ob_sval , (int ) a -> ob_size );
795779 op -> ob_sval [size ] = '\0' ;
@@ -945,15 +929,11 @@ string_hash(PyStringObject *a)
945929 register unsigned char * p ;
946930 register long x ;
947931
948- #ifdef CACHE_HASH
949932 if (a -> ob_shash != -1 )
950933 return a -> ob_shash ;
951- #ifdef INTERN_STRINGS
952934 if (a -> ob_sinterned != NULL )
953935 return (a -> ob_shash =
954936 ((PyStringObject * )(a -> ob_sinterned ))-> ob_shash );
955- #endif
956- #endif
957937 len = a -> ob_size ;
958938 p = (unsigned char * ) a -> ob_sval ;
959939 x = * p << 7 ;
@@ -962,9 +942,7 @@ string_hash(PyStringObject *a)
962942 x ^= a -> ob_size ;
963943 if (x == -1 )
964944 x = -2 ;
965- #ifdef CACHE_HASH
966945 a -> ob_shash = x ;
967- #endif
968946 return x ;
969947}
970948
@@ -2730,14 +2708,10 @@ str_subtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
27302708 pnew = type -> tp_alloc (type , n );
27312709 if (pnew != NULL ) {
27322710 memcpy (PyString_AS_STRING (pnew ), PyString_AS_STRING (tmp ), n + 1 );
2733- #ifdef CACHE_HASH
27342711 ((PyStringObject * )pnew )-> ob_shash =
27352712 ((PyStringObject * )tmp )-> ob_shash ;
2736- #endif
2737- #ifdef INTERN_STRINGS
27382713 ((PyStringObject * )pnew )-> ob_sinterned =
27392714 ((PyStringObject * )tmp )-> ob_sinterned ;
2740- #endif
27412715 }
27422716 Py_DECREF (tmp );
27432717 return pnew ;
@@ -3579,7 +3553,6 @@ PyString_Format(PyObject *format, PyObject *args)
35793553}
35803554
35813555
3582- #ifdef INTERN_STRINGS
35833556
35843557/* This dictionary will leak at PyString_Fini() time. That's acceptable
35853558 * because PyString_Fini() specifically frees interned strings that are
@@ -3656,8 +3629,6 @@ PyString_InternFromString(const char *cp)
36563629 return s ;
36573630}
36583631
3659- #endif
3660-
36613632void
36623633PyString_Fini (void )
36633634{
@@ -3670,7 +3641,6 @@ PyString_Fini(void)
36703641 Py_XDECREF (nullstring );
36713642 nullstring = NULL ;
36723643#endif
3673- #ifdef INTERN_STRINGS
36743644 if (interned ) {
36753645 int pos , changed ;
36763646 PyObject * key , * value ;
@@ -3685,10 +3655,8 @@ PyString_Fini(void)
36853655 }
36863656 } while (changed );
36873657 }
3688- #endif
36893658}
36903659
3691- #ifdef INTERN_STRINGS
36923660void _Py_ReleaseInternedStrings (void )
36933661{
36943662 if (interned ) {
@@ -3698,4 +3666,3 @@ void _Py_ReleaseInternedStrings(void)
36983666 interned = NULL ;
36993667 }
37003668}
3701- #endif /* INTERN_STRINGS */
0 commit comments