summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2002-03-30 10:06:07 (GMT)
committerTim Peters <tim.peters@gmail.com>2002-03-30 10:06:07 (GMT)
commit8deda70b16c0683c3d8718f751d8668f13977c70 (patch)
tree3f0eab6931ed8fcbe3595671e5b0ed2b28a01b9e /Objects
parent522cf1f6fb2dab78702af1f1f06b0855fab75149 (diff)
downloadcpython-8deda70b16c0683c3d8718f751d8668f13977c70.zip
cpython-8deda70b16c0683c3d8718f751d8668f13977c70.tar.gz
cpython-8deda70b16c0683c3d8718f751d8668f13977c70.tar.bz2
Eliminate DONT_SHARE_SHORT_STRINGS.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/stringobject.c14
1 files changed, 2 insertions, 12 deletions
diff --git a/Objects/stringobject.c b/Objects/stringobject.c
index d8e6ff8..144c5b0 100644
--- a/Objects/stringobject.c
+++ b/Objects/stringobject.c
@@ -14,9 +14,7 @@ int null_strings, one_strings;
#endif
static PyStringObject *characters[UCHAR_MAX + 1];
-#ifndef DONT_SHARE_SHORT_STRINGS
static PyStringObject *nullstring;
-#endif
/*
For both PyString_FromString() and PyString_FromStringAndSize(), the
@@ -47,7 +45,6 @@ PyObject *
PyString_FromStringAndSize(const char *str, int size)
{
register PyStringObject *op;
-#ifndef DONT_SHARE_SHORT_STRINGS
if (size == 0 && (op = nullstring) != NULL) {
#ifdef COUNT_ALLOCS
null_strings++;
@@ -64,7 +61,6 @@ PyString_FromStringAndSize(const char *str, int size)
Py_INCREF(op);
return (PyObject *)op;
}
-#endif /* DONT_SHARE_SHORT_STRINGS */
/* PyObject_NewVar is inlined */
op = (PyStringObject *)
@@ -77,7 +73,7 @@ PyString_FromStringAndSize(const char *str, int size)
if (str != NULL)
memcpy(op->ob_sval, str, size);
op->ob_sval[size] = '\0';
-#ifndef DONT_SHARE_SHORT_STRINGS
+ /* share short strings */
if (size == 0) {
PyObject *t = (PyObject *)op;
PyString_InternInPlace(&t);
@@ -91,7 +87,6 @@ PyString_FromStringAndSize(const char *str, int size)
characters[*str & UCHAR_MAX] = op;
Py_INCREF(op);
}
-#endif
return (PyObject *) op;
}
@@ -108,7 +103,6 @@ PyString_FromString(const char *str)
"string is too long for a Python string");
return NULL;
}
-#ifndef DONT_SHARE_SHORT_STRINGS
if (size == 0 && (op = nullstring) != NULL) {
#ifdef COUNT_ALLOCS
null_strings++;
@@ -123,7 +117,6 @@ PyString_FromString(const char *str)
Py_INCREF(op);
return (PyObject *)op;
}
-#endif /* DONT_SHARE_SHORT_STRINGS */
/* PyObject_NewVar is inlined */
op = (PyStringObject *)
@@ -134,7 +127,7 @@ PyString_FromString(const char *str)
op->ob_shash = -1;
op->ob_sinterned = NULL;
memcpy(op->ob_sval, str, size+1);
-#ifndef DONT_SHARE_SHORT_STRINGS
+ /* share short strings */
if (size == 0) {
PyObject *t = (PyObject *)op;
PyString_InternInPlace(&t);
@@ -148,7 +141,6 @@ PyString_FromString(const char *str)
characters[*str & UCHAR_MAX] = op;
Py_INCREF(op);
}
-#endif
return (PyObject *) op;
}
@@ -3637,10 +3629,8 @@ PyString_Fini(void)
Py_XDECREF(characters[i]);
characters[i] = NULL;
}
-#ifndef DONT_SHARE_SHORT_STRINGS
Py_XDECREF(nullstring);
nullstring = NULL;
-#endif
if (interned) {
int pos, changed;
PyObject *key, *value;