Submitter | Boris Feld |
---|---|
Date | Nov. 15, 2018, 10:38 a.m. |
Message ID | <d8b70c216567aebbd5ae.1542278324@localhost.localdomain> |
Download | mbox | patch |
Permalink | /patch/36595/ |
State | Accepted |
Headers | show |
Comments
On Thu, 15 Nov 2018 11:38:44 +0100, Boris Feld wrote: > # HG changeset patch > # User Boris Feld <boris.feld@octobus.net> > # Date 1541785396 -3600 > # Fri Nov 09 18:43:16 2018 +0100 > # Node ID d8b70c216567aebbd5aeabf0cbee2ce192212e0e > # Parent 7d80481596f245d7f299c8a473907a22f2f3c947 > # EXP-Topic sparse-perf > # Available At https://bitbucket.org/octobus/mercurial-devel/ > # hg pull https://bitbucket.org/octobus/mercurial-devel/ -r d8b70c216567 > sparse-revlog: add a `index_segment_span` 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 > @@ -1023,6 +1023,14 @@ bail: > return NULL; > } > > +static inline long index_segment_span(indexObject *self, Py_ssize_t start_rev, > + Py_ssize_t end_rev) > +{ > + return (index_get_start(self, end_rev) - > + index_get_start(self, start_rev) + > + index_get_length(self, end_rev)); So this is uint64_t - uint64_t + int -> long. I'm not certain what kind of implicit integer conversion is intended. Can you add explicit cast to each term?
Patch
diff --git a/mercurial/cext/revlog.c b/mercurial/cext/revlog.c --- a/mercurial/cext/revlog.c +++ b/mercurial/cext/revlog.c @@ -1023,6 +1023,14 @@ bail: return NULL; } +static inline long index_segment_span(indexObject *self, Py_ssize_t start_rev, + Py_ssize_t end_rev) +{ + return (index_get_start(self, end_rev) - + index_get_start(self, start_rev) + + index_get_length(self, end_rev)); +} + static inline int nt_level(const char *node, Py_ssize_t level) { int v = node[level >> 1];