Mercurial > hg
comparison mercurial/parsers.c @ 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 | 473a63c45394 |
comparison
equal
deleted
inserted
replaced
26213:4d6cdea33f37 | 26214:46605888faf3 |
---|---|
2634 left = PyString_FromStringAndSize(meta, metasize); | 2634 left = PyString_FromStringAndSize(meta, metasize); |
2635 meta += metasize; | 2635 meta += metasize; |
2636 metasize = (unsigned char)(*data++); | 2636 metasize = (unsigned char)(*data++); |
2637 right = PyString_FromStringAndSize(meta, metasize); | 2637 right = PyString_FromStringAndSize(meta, metasize); |
2638 meta += metasize; | 2638 meta += metasize; |
2639 if (!left || !right) { | 2639 tmp = PyTuple_New(2); |
2640 if (!left || !right || !tmp) { | |
2640 Py_XDECREF(left); | 2641 Py_XDECREF(left); |
2641 Py_XDECREF(right); | 2642 Py_XDECREF(right); |
2642 goto bail; | 2643 Py_XDECREF(tmp); |
2643 } | 2644 goto bail; |
2644 tmp = PyTuple_Pack(2, left, right); | 2645 } |
2645 Py_DECREF(left); | 2646 PyTuple_SET_ITEM(tmp, 0, left); |
2646 Py_DECREF(right); | 2647 PyTuple_SET_ITEM(tmp, 1, right); |
2647 if (!tmp) { | |
2648 goto bail; | |
2649 } | |
2650 PyTuple_SET_ITEM(metadata, i, tmp); | 2648 PyTuple_SET_ITEM(metadata, i, tmp); |
2651 } | 2649 } |
2652 ret = Py_BuildValue("(OOHO(di)O)", prec, succs, flags, | 2650 ret = Py_BuildValue("(OOHO(di)O)", prec, succs, flags, |
2653 metadata, mtime, (int)tz * 60, parents); | 2651 metadata, mtime, (int)tz * 60, parents); |
2654 bail: | 2652 bail: |