[Python-checkins] r68868 - python/branches/py3k/Modules/_pickle.c
alexandre.vassalotti
python-checkins at python.org
Fri Jan 23 05:43:46 CET 2009
Author: alexandre.vassalotti
Date: Fri Jan 23 05:43:46 2009
New Revision: 68868
Log:
Remove unnecessary copying in load_long().
Modified:
python/branches/py3k/Modules/_pickle.c
Modified: python/branches/py3k/Modules/_pickle.c
==============================================================================
--- python/branches/py3k/Modules/_pickle.c (original)
+++ python/branches/py3k/Modules/_pickle.c Fri Jan 23 05:43:46 2009
@@ -2881,7 +2881,7 @@
load_long(UnpicklerObject *self)
{
PyObject *value;
- char *s, *ss;
+ char *s;
Py_ssize_t len;
if ((len = unpickler_readline(self, &s)) < 0)
@@ -2894,17 +2894,9 @@
compatibility with Python 3.0.0, we don't actually *require*
the 'L' to be present. */
if (s[len-2] == 'L') {
- ss = (char *)PyMem_Malloc(len-1);
- if (ss == NULL) {
- PyErr_NoMemory();
- return -1;
- }
- strncpy(ss, s, len-2);
- ss[len-2] = '\0';
-
+ s[len-2] = '\0';
/* XXX: Should the base argument explicitly set to 10? */
- value = PyLong_FromString(ss, NULL, 0);
- PyMem_Free(ss);
+ value = PyLong_FromString(s, NULL, 0);
}
else {
value = PyLong_FromString(s, NULL, 0);
More information about the Python-checkins
mailing list