From patchwork Mon Dec 14 18:49:24 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [3,of,4] parsers: use PyTuple_Pack instead of manual list-filling From: Bryan O'Sullivan X-Patchwork-Id: 12034 Message-Id: To: mercurial-devel@selenic.com Date: Mon, 14 Dec 2015 10:49:24 -0800 # HG changeset patch # User Bryan O'Sullivan # Date 1450118846 28800 # Mon Dec 14 10:47:26 2015 -0800 # Node ID c7cd7212c41596731c246ebc8d006a76e437fa5c # Parent 13a42f5695ac05f1a684070d5e6516286dc4ce8d parsers: use PyTuple_Pack instead of manual list-filling Suggested by Yuya. diff --git a/mercurial/parsers.c b/mercurial/parsers.c --- a/mercurial/parsers.c +++ b/mercurial/parsers.c @@ -1351,12 +1351,8 @@ static PyObject *compute_phases_map_sets goto release; PyList_SET_ITEM(phaseslist, i, phaseval); } - ret = PyList_New(2); - if (ret == NULL) - goto release; - - PyList_SET_ITEM(ret, 0, phaseslist); - PyList_SET_ITEM(ret, 1, phasessetlist); + ret = PyTuple_Pack(2, phaseslist, phasessetlist); + /* We don't release phaseslist and phasessetlist as we return them to * python */ goto done;