changeset 47945:3337eec29d5b

dirstate-item: `dirstate_item_from_v1_data` replaces make_dirstate_item For different format, we will need multiple capsule anyways. Differential Revision: https://phab.mercurial-scm.org/D11384
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Fri, 27 Aug 2021 19:19:21 +0200
parents e02f9af7aed1
children 0919d66e279a
files mercurial/cext/parsers.c
diffstat 1 files changed, 3 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/cext/parsers.c	Mon Aug 30 18:45:54 2021 +0200
+++ b/mercurial/cext/parsers.c	Fri Aug 27 19:19:21 2021 +0200
@@ -44,21 +44,6 @@
 	return _dict_new_presized(expected_size);
 }
 
-static inline dirstateItemObject *make_dirstate_item(char state, int mode,
-                                                     int size, int mtime)
-{
-	dirstateItemObject *t =
-	    PyObject_New(dirstateItemObject, &dirstateItemType);
-	if (!t) {
-		return NULL;
-	}
-	t->state = state;
-	t->mode = mode;
-	t->size = size;
-	t->mtime = mtime;
-	return t;
-}
-
 static PyObject *dirstate_item_new(PyTypeObject *subtype, PyObject *args,
                                    PyObject *kwds)
 {
@@ -201,7 +186,7 @@
 	}
 };
 
-/* This will never change since it's bound to V1, unlike `make_dirstate_item`
+/* This will never change since it's bound to V1
  */
 static inline dirstateItemObject *
 dirstate_item_from_v1_data(char state, int mode, int size, int mtime)
@@ -795,7 +780,7 @@
 			/* See pure/parsers.py:pack_dirstate for why we do
 			 * this. */
 			mtime = -1;
-			mtime_unset = (PyObject *)make_dirstate_item(
+			mtime_unset = (PyObject *)dirstate_item_from_v1_data(
 			    state, mode, size, mtime);
 			if (!mtime_unset) {
 				goto bail;
@@ -1088,7 +1073,7 @@
 	revlog_module_init(mod);
 
 	capsule = PyCapsule_New(
-	    make_dirstate_item,
+	    dirstate_item_from_v1_data,
 	    "mercurial.cext.parsers.make_dirstate_item_CAPI", NULL);
 	if (capsule != NULL)
 		PyModule_AddObject(mod, "make_dirstate_item_CAPI", capsule);