Mercurial > cpython-lru_cache-weakref
diff Objects/stringobject.c @ 22689:614167df2096 legacy-trunk
Eliminate DONT_SHARE_SHORT_STRINGS.
| author | Tim Peters <tim.peters@gmail.com> |
|---|---|
| date | Sat, 30 Mar 2002 10:06:07 +0000 |
| parents | f3a416b178c4 |
| children | aa8d59823add |
line wrap: on
line diff
--- a/Objects/stringobject.c Sat Mar 30 08:57:12 2002 +0000 +++ b/Objects/stringobject.c Sat Mar 30 10:06:07 2002 +0000 @@ -14,9 +14,7 @@ #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 @@ 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 @@ Py_INCREF(op); return (PyObject *)op; } -#endif /* DONT_SHARE_SHORT_STRINGS */ /* PyObject_NewVar is inlined */ op = (PyStringObject *) @@ -77,7 +73,7 @@ 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 @@ characters[*str & UCHAR_MAX] = op; Py_INCREF(op); } -#endif return (PyObject *) op; } @@ -108,7 +103,6 @@ "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 @@ Py_INCREF(op); return (PyObject *)op; } -#endif /* DONT_SHARE_SHORT_STRINGS */ /* PyObject_NewVar is inlined */ op = (PyStringObject *) @@ -134,7 +127,7 @@ 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 @@ characters[*str & UCHAR_MAX] = op; Py_INCREF(op); } -#endif return (PyObject *) op; } @@ -3637,10 +3629,8 @@ 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;
