Patchwork D11385: dirstate-item: factor some code in the C implementation

login
register
mail settings
Submitter phabricator
Date Sept. 1, 2021, 11:36 p.m.
Message ID <differential-rev-PHID-DREV-jyrdomdiam6zhb62ezri-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/49700/
State Superseded
Headers show

Comments

phabricator - Sept. 1, 2021, 11:36 p.m.
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  We have both `dirstate_item_from_v1_meth`, a class method, and
  `dirstate_item_from_v1_data`, a function taking low level C argument.
  
  Lets implement the former with the later.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/cext/parsers.c

CHANGE DETAILS




To: marmoute, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/mercurial/cext/parsers.c b/mercurial/cext/parsers.c
--- a/mercurial/cext/parsers.c
+++ b/mercurial/cext/parsers.c
@@ -209,23 +209,12 @@ 
 {
 	/* We do all the initialization here and not a tp_init function because
 	 * dirstate_item is immutable. */
-	dirstateItemObject *t;
 	char state;
 	int size, mode, mtime;
 	if (!PyArg_ParseTuple(args, "ciii", &state, &mode, &size, &mtime)) {
 		return NULL;
 	}
-
-	t = (dirstateItemObject *)subtype->tp_alloc(subtype, 1);
-	if (!t) {
-		return NULL;
-	}
-	t->state = state;
-	t->mode = mode;
-	t->size = size;
-	t->mtime = mtime;
-
-	return (PyObject *)t;
+	return (PyObject *)dirstate_item_from_v1_data(state, mode, size, mtime);
 };
 
 /* constructor to help legacy API to build a new "added" item