diff Objects/stringobject.c @ 1380:a4aa83012af3 legacy-trunk

Fixed bugs in resizetuple and extended the interface. Added ifdefs in stringobject.c for shared strings of length 1. Renamed free_list in tupleobject.c to free_tuples.
author Sjoerd Mullender <sjoerd@acm.org>
date Mon, 01 Nov 1993 13:46:50 +0000
parents 4c8e5fcb3301
children 18df674539da
line wrap: on
line diff
--- a/Objects/stringobject.c	Sat Oct 30 12:39:49 1993 +0000
+++ b/Objects/stringobject.c	Mon Nov 01 13:46:50 1993 +0000
@@ -39,7 +39,9 @@
 #endif
 
 static stringobject *characters[UCHAR_MAX + 1];
+#ifndef DONT_SHARE_SHORT_STRINGS
 static stringobject *nullstring;
+#endif
 
 /*
    Newsizedstringobject() and newstringobject() try in certain cases
@@ -62,6 +64,7 @@
 	int size;
 {
 	register stringobject *op;
+#ifndef DONT_SHARE_SHORT_STRINGS
 	if (size == 0 && (op = nullstring) != NULL) {
 #ifdef COUNT_ALLOCS
 		null_strings++;
@@ -76,6 +79,7 @@
 		INCREF(op);
 		return (object *)op;
 	}
+#endif /* DONT_SHARE_SHORT_STRINGS */
 	op = (stringobject *)
 		malloc(sizeof(stringobject) + size * sizeof(char));
 	if (op == NULL)
@@ -89,6 +93,7 @@
 	if (str != NULL)
 		memcpy(op->ob_sval, str, size);
 	op->ob_sval[size] = '\0';
+#ifndef DONT_SHARE_SHORT_STRINGS
 	if (size == 0) {
 		nullstring = op;
 		INCREF(op);
@@ -96,6 +101,7 @@
 		characters[*str & UCHAR_MAX] = op;
 		INCREF(op);
 	}
+#endif
 	return (object *) op;
 }
 
@@ -105,6 +111,7 @@
 {
 	register unsigned int size = strlen(str);
 	register stringobject *op;
+#ifndef DONT_SHARE_SHORT_STRINGS
 	if (size == 0 && (op = nullstring) != NULL) {
 #ifdef COUNT_ALLOCS
 		null_strings++;
@@ -119,6 +126,7 @@
 		INCREF(op);
 		return (object *)op;
 	}
+#endif /* DONT_SHARE_SHORT_STRINGS */
 	op = (stringobject *)
 		malloc(sizeof(stringobject) + size * sizeof(char));
 	if (op == NULL)
@@ -130,6 +138,7 @@
 #endif
 	NEWREF(op);
 	strcpy(op->ob_sval, str);
+#ifndef DONT_SHARE_SHORT_STRINGS
 	if (size == 0) {
 		nullstring = op;
 		INCREF(op);
@@ -137,6 +146,7 @@
 		characters[*str & UCHAR_MAX] = op;
 		INCREF(op);
 	}
+#endif
 	return (object *) op;
 }