[PATCH 2 of 3] dirs.c: extract 'cpath' variable in _delpath() to match _addpath()

Ryan McElroy rmcelroy at fb.com
Thu May 14 18:28:18 CDT 2015


# HG changeset patch
# User Martin von Zweigbergk <martinvonz at google.com>
# Date 1431119460 25200
#      Fri May 08 14:11:00 2015 -0700
# Node ID 6ea5874db04c722bcd5ec8c5341eb242aa894296
# Parent  f749a75992f4750cf9b4bc33226147944819f283
dirs.c: extract 'cpath' variable in _delpath() to match _addpath()

The PyString_AS_STRING() macro is probably free, but this makes
_delpath() more similar to _addpath() and simplifies the next patch.

diff --git a/mercurial/dirs.c b/mercurial/dirs.c
--- a/mercurial/dirs.c
+++ b/mercurial/dirs.c
@@ -95,6 +95,7 @@
 
 static int _delpath(PyObject *dirs, PyObject *path)
 {
+	char *cpath = PyString_AS_STRING(path);
 	Py_ssize_t pos = PyString_GET_SIZE(path);
 	PyObject *key = NULL;
 	int ret = -1;
@@ -102,7 +103,7 @@
 	while ((pos = _finddir(path, pos - 1)) != -1) {
 		PyObject *val;
 
-		key = PyString_FromStringAndSize(PyString_AS_STRING(path), pos);
+		key = PyString_FromStringAndSize(cpath, pos);
 
 		if (key == NULL)
 			goto bail;


More information about the Mercurial-devel mailing list