Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 169192e

Browse files
committed
SF patch #491049 (David Jacobs): Small PyString_FromString optimization
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.
1 parent 49bdaed commit 169192e

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

Objects/stringobject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ PyString_FromString(const char *str)
144144
#ifdef INTERN_STRINGS
145145
op->ob_sinterned = NULL;
146146
#endif
147-
strcpy(op->ob_sval, str);
147+
memcpy(op->ob_sval, str, size+1);
148148
#ifndef DONT_SHARE_SHORT_STRINGS
149149
if (size == 0) {
150150
PyObject *t = (PyObject *)op;

0 commit comments

Comments
 (0)