changeset 26214:46605888faf3

parsers: use PyTuple_New and SET_ITEM to construct metadata pair of markers With these 2 patches, fm1readmarkers() gets slightly faster: obsolete._fm1readmarkers() for 78644 entries 58.0 -> 56.2msec
author Yuya Nishihara <yuya@tcha.org>
date Sat, 05 Sep 2015 16:50:35 +0900
parents 4d6cdea33f37
children 72aad184f061
files mercurial/parsers.c
diffstat 1 files changed, 5 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/parsers.c	Sat Sep 05 16:41:21 2015 +0900
+++ b/mercurial/parsers.c	Sat Sep 05 16:50:35 2015 +0900
@@ -2636,17 +2636,15 @@
 		metasize = (unsigned char)(*data++);
 		right = PyString_FromStringAndSize(meta, metasize);
 		meta += metasize;
-		if (!left || !right) {
+		tmp = PyTuple_New(2);
+		if (!left || !right || !tmp) {
 			Py_XDECREF(left);
 			Py_XDECREF(right);
+			Py_XDECREF(tmp);
 			goto bail;
 		}
-		tmp = PyTuple_Pack(2, left, right);
-		Py_DECREF(left);
-		Py_DECREF(right);
-		if (!tmp) {
-			goto bail;
-		}
+		PyTuple_SET_ITEM(tmp, 0, left);
+		PyTuple_SET_ITEM(tmp, 1, right);
 		PyTuple_SET_ITEM(metadata, i, tmp);
 	}
 	ret = Py_BuildValue("(OOHO(di)O)", prec, succs, flags,