]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
SF patch #491049 (David Jacobs): Small PyString_FromString optimization
authorGuido van Rossum <guido@python.org>
Mon, 10 Dec 2001 15:45:54 +0000 (15:45 +0000)
committerGuido van Rossum <guido@python.org>
Mon, 10 Dec 2001 15:45:54 +0000 (15:45 +0000)
PyString_FromString():
  Since the length of the string is already being stored in size,
  changed the strcpy() to a memcpy() for a small speed improvement.

Objects/stringobject.c

index 657b20093b92c39445678405e7f7a3cab245846d..992f3d95ec218791bcd4b8d3a8be425836dbd297 100644 (file)
@@ -144,7 +144,7 @@ PyString_FromString(const char *str)
 #ifdef INTERN_STRINGS
        op->ob_sinterned = NULL;
 #endif
-       strcpy(op->ob_sval, str);
+       memcpy(op->ob_sval, str, size+1);
 #ifndef DONT_SHARE_SHORT_STRINGS
        if (size == 0) {
                PyObject *t = (PyObject *)op;