Submitter | Boris Feld |
---|---|
Date | Nov. 15, 2018, 10:38 a.m. |
Message ID | <f78fcec5ba387ff17ace.1542278322@localhost.localdomain> |
Download | mbox | patch |
Permalink | /patch/36594/ |
State | Accepted |
Headers | show |
Comments
On Thu, 15 Nov 2018 11:38:42 +0100, Boris Feld wrote: > # HG changeset patch > # User Boris Feld <boris.feld@octobus.net> > # Date 1541785348 -3600 > # Fri Nov 09 18:42:28 2018 +0100 > # Node ID f78fcec5ba387ff17ace7ca99294a90c7ba92387 > # Parent 20e272f4f88c761b61556b4a4db08890fac21f56 > # EXP-Topic sparse-perf > # Available At https://bitbucket.org/octobus/mercurial-devel/ > # hg pull https://bitbucket.org/octobus/mercurial-devel/ -r f78fcec5ba38 > sparse-revlog: add a `index_get_start` function in C > > We are about to implement a native version of `slicechunktodensity`. For > clarity, we introduce the helper functions first. This new function provides > an efficient way to retrieve some of the information needed by > `slicechunktodensity`. > > diff --git a/mercurial/cext/revlog.c b/mercurial/cext/revlog.c > --- a/mercurial/cext/revlog.c > +++ b/mercurial/cext/revlog.c > @@ -185,6 +185,27 @@ static inline int index_get_parents(inde > return 0; > } > > +static inline uint64_t index_get_start(indexObject *self, Py_ssize_t rev) > +{ > + uint64_t offset; > + if (rev >= self->length) { > + PyObject *tuple = > + PyList_GET_ITEM(self->added, rev - self->length); > + offset = (uint64_t)PyInt_AS_LONG(PyTuple_GET_ITEM(tuple, 0)); Can you update this and the next patch to use pylong_to_long(). PyInt_AS_LONG() is brain damaged on Python 3.
On 16/11/2018 13:11, Yuya Nishihara wrote: > On Thu, 15 Nov 2018 11:38:42 +0100, Boris Feld wrote: >> # HG changeset patch >> # User Boris Feld <boris.feld@octobus.net> >> # Date 1541785348 -3600 >> # Fri Nov 09 18:42:28 2018 +0100 >> # Node ID f78fcec5ba387ff17ace7ca99294a90c7ba92387 >> # Parent 20e272f4f88c761b61556b4a4db08890fac21f56 >> # EXP-Topic sparse-perf >> # Available At https://bitbucket.org/octobus/mercurial-devel/ >> # hg pull https://bitbucket.org/octobus/mercurial-devel/ -r f78fcec5ba38 >> sparse-revlog: add a `index_get_start` function in C >> >> We are about to implement a native version of `slicechunktodensity`. For >> clarity, we introduce the helper functions first. This new function provides >> an efficient way to retrieve some of the information needed by >> `slicechunktodensity`. >> >> diff --git a/mercurial/cext/revlog.c b/mercurial/cext/revlog.c >> --- a/mercurial/cext/revlog.c >> +++ b/mercurial/cext/revlog.c >> @@ -185,6 +185,27 @@ static inline int index_get_parents(inde >> return 0; >> } >> >> +static inline uint64_t index_get_start(indexObject *self, Py_ssize_t rev) >> +{ >> + uint64_t offset; >> + if (rev >= self->length) { >> + PyObject *tuple = >> + PyList_GET_ITEM(self->added, rev - self->length); >> + offset = (uint64_t)PyInt_AS_LONG(PyTuple_GET_ITEM(tuple, 0)); > Can you update this and the next patch to use pylong_to_long(). PyInt_AS_LONG() > is brain damaged on Python 3. This is fixed in the V3 that I will send shortly. This had a significant impact on the full series as the possible error raised by pylong_to_long had to be propagated along the caller chain. > _______________________________________________ > Mercurial-devel mailing list > Mercurial-devel@mercurial-scm.org > https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Patch
diff --git a/mercurial/cext/revlog.c b/mercurial/cext/revlog.c --- a/mercurial/cext/revlog.c +++ b/mercurial/cext/revlog.c @@ -185,6 +185,27 @@ static inline int index_get_parents(inde return 0; } +static inline uint64_t index_get_start(indexObject *self, Py_ssize_t rev) +{ + uint64_t offset; + if (rev >= self->length) { + PyObject *tuple = + PyList_GET_ITEM(self->added, rev - self->length); + offset = (uint64_t)PyInt_AS_LONG(PyTuple_GET_ITEM(tuple, 0)); + } else { + const char *data = index_deref(self, rev); + offset = getbe32(data + 4); + if (rev == 0) /* mask out version number for the first entry */ + offset &= 0xFFFF; + else { + uint32_t offset_high = getbe32(data); + offset |= ((uint64_t)offset_high) << 32; + } + } + offset = offset >> 16; + return offset; +} + /* * RevlogNG format (all in big endian, data may be inlined): * 6 bytes: offset