mirror of
https://github.com/python/cpython.git
synced 2025-10-22 14:42:22 +00:00
Remove unnecessary copying in load_long().
This commit is contained in:
parent
aa06900347
commit
446f7ffa0f
1 changed files with 3 additions and 11 deletions
|
@ -2881,7 +2881,7 @@ static int
|
||||||
load_long(UnpicklerObject *self)
|
load_long(UnpicklerObject *self)
|
||||||
{
|
{
|
||||||
PyObject *value;
|
PyObject *value;
|
||||||
char *s, *ss;
|
char *s;
|
||||||
Py_ssize_t len;
|
Py_ssize_t len;
|
||||||
|
|
||||||
if ((len = unpickler_readline(self, &s)) < 0)
|
if ((len = unpickler_readline(self, &s)) < 0)
|
||||||
|
@ -2894,17 +2894,9 @@ load_long(UnpicklerObject *self)
|
||||||
compatibility with Python 3.0.0, we don't actually *require*
|
compatibility with Python 3.0.0, we don't actually *require*
|
||||||
the 'L' to be present. */
|
the 'L' to be present. */
|
||||||
if (s[len-2] == 'L') {
|
if (s[len-2] == 'L') {
|
||||||
ss = (char *)PyMem_Malloc(len-1);
|
s[len-2] = '\0';
|
||||||
if (ss == NULL) {
|
|
||||||
PyErr_NoMemory();
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
strncpy(ss, s, len-2);
|
|
||||||
ss[len-2] = '\0';
|
|
||||||
|
|
||||||
/* XXX: Should the base argument explicitly set to 10? */
|
/* XXX: Should the base argument explicitly set to 10? */
|
||||||
value = PyLong_FromString(ss, NULL, 0);
|
value = PyLong_FromString(s, NULL, 0);
|
||||||
PyMem_Free(ss);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
value = PyLong_FromString(s, NULL, 0);
|
value = PyLong_FromString(s, NULL, 0);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue