[PATCH 06 of 10 V2] sparse-revlog: add a `index_segment_span` function in C
Boris Feld
boris.feld at octobus.net
Thu Nov 15 05:38:44 EST 2018
# HG changeset patch
# User Boris Feld <boris.feld at 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));
+}
+
static inline int nt_level(const char *node, Py_ssize_t level)
{
int v = node[level >> 1];
More information about the Mercurial-devel
mailing list