Patchwork [3,of,4] parsers: use PyTuple_Pack instead of manual list-filling

login
register
mail settings
Submitter Bryan O'Sullivan
Date Dec. 14, 2015, 6:49 p.m.
Message ID <c7cd7212c41596731c24.1450118964@bryano-mbp.local>
Download mbox | patch
Permalink /patch/12034/
State Superseded
Delegated to: Yuya Nishihara
Headers show

Comments

Bryan O'Sullivan - Dec. 14, 2015, 6:49 p.m.
# HG changeset patch
# User Bryan O'Sullivan <bos@serpentine.com>
# 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.

Patch

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;