diff options
author | Bob Ippolito <bob@redivi.com> | 2008-10-11 18:05:21 +0000 |
---|---|---|
committer | Bob Ippolito <bob@redivi.com> | 2008-10-11 18:05:21 +0000 |
commit | 34c500828f64054b6a74de1cbb3bcad4e5bc10c1 (patch) | |
tree | 8075930e19e6abe0d443276e1a1b0db1e6eb4c14 | |
parent | 2d906dc32497b521edbfadfa29b4808f5dbb7bc8 (diff) | |
download | simplejson-34c500828f64054b6a74de1cbb3bcad4e5bc10c1.tar.gz |
use PyTuple_New and PyTuple_SET_ITEM to skip some refcounting games, although we should probably skip creating these tuples all together
git-svn-id: http://simplejson.googlecode.com/svn/trunk@142 a4795897-2c25-0410-b006-0d3caba88fa1
-rw-r--r-- | simplejson/_speedups.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/simplejson/_speedups.c b/simplejson/_speedups.c index e03f995..d6def49 100644 --- a/simplejson/_speedups.c +++ b/simplejson/_speedups.c @@ -368,9 +368,14 @@ _build_rval_index_tuple(PyObject *rval, Py_ssize_t idx) { Py_DECREF(rval); return NULL; } - tpl = PyTuple_Pack(2, rval, pyidx); - Py_DECREF(pyidx); - Py_DECREF(rval); + tpl = PyTuple_New(2); + if (tpl == NULL) { + Py_DECREF(pyidx); + Py_DECREF(rval); + return NULL; + } + PyTuple_SET_ITEM(tpl, 0, rval); + PyTuple_SET_ITEM(tpl, 1, pyidx); return tpl; } |