Patchwork D4112: index: add pointer from nodetree back to index

login
register
mail settings
Submitter phabricator
Date Aug. 7, 2018, 6:27 a.m.
Message ID <3a406833ca18719f87a00f7d89e295ff@localhost.localdomain>
Download mbox | patch
Permalink /patch/33381/
State Not Applicable
Headers show

Comments

phabricator - Aug. 7, 2018, 6:27 a.m.
martinvonz updated this revision to Diff 10036.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D4112?vs=9977&id=10036

REVISION DETAIL
  https://phab.mercurial-scm.org/D4112

AFFECTED FILES
  mercurial/cext/revlog.c

CHANGE DETAILS




To: martinvonz, #hg-reviewers
Cc: 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
@@ -28,6 +28,8 @@ 
 #define PyInt_AsLong PyLong_AsLong
 #endif
 
+typedef struct indexObjectStruct indexObject;
+
 typedef struct {
 	int children[16];
 } nodetreenode;
@@ -40,6 +42,7 @@ 
  * Zero is empty
  */
 typedef struct {
+	indexObject *index;
 	nodetreenode *nodes;
 	unsigned length;     /* # nodes in use */
 	unsigned capacity;   /* # nodes allocated */
@@ -59,7 +62,7 @@ 
  * With string keys, we lazily perform a reverse mapping from node to
  * rev, using a base-16 trie.
  */
-typedef struct {
+struct indexObjectStruct {
 	PyObject_HEAD
 	/* Type-specific fields go here. */
 	PyObject *data;        /* raw bytes of index */
@@ -76,7 +79,7 @@ 
 	int ntlookups;         /* # lookups */
 	int ntmisses;          /* # lookups that miss the cache */
 	int inlined;
-} indexObject;
+};
 
 static Py_ssize_t index_length(const indexObject *self)
 {
@@ -1120,6 +1123,7 @@ 
 		self->nt->depth = 0;
 		self->nt->splits = 0;
 		self->nt->length = 1;
+		self->nt->index = self;
 		if (nt_insert(self, nullid, -1) == -1) {
 			free(self->nt->nodes);
 			PyMem_Free(self->nt);