Mercurial > hg
comparison mercurial/dirs.c @ 25092:f41539418b41
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.
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Fri, 08 May 2015 14:11:00 -0700 |
parents | 42e89b87ca79 |
children | fe3a72a3e7ca |
comparison
equal
deleted
inserted
replaced
25091:b5052fc73300 | 25092:f41539418b41 |
---|---|
93 return ret; | 93 return ret; |
94 } | 94 } |
95 | 95 |
96 static int _delpath(PyObject *dirs, PyObject *path) | 96 static int _delpath(PyObject *dirs, PyObject *path) |
97 { | 97 { |
98 char *cpath = PyString_AS_STRING(path); | |
98 Py_ssize_t pos = PyString_GET_SIZE(path); | 99 Py_ssize_t pos = PyString_GET_SIZE(path); |
99 PyObject *key = NULL; | 100 PyObject *key = NULL; |
100 int ret = -1; | 101 int ret = -1; |
101 | 102 |
102 while ((pos = _finddir(path, pos - 1)) != -1) { | 103 while ((pos = _finddir(path, pos - 1)) != -1) { |
103 PyObject *val; | 104 PyObject *val; |
104 | 105 |
105 key = PyString_FromStringAndSize(PyString_AS_STRING(path), pos); | 106 key = PyString_FromStringAndSize(cpath, pos); |
106 | 107 |
107 if (key == NULL) | 108 if (key == NULL) |
108 goto bail; | 109 goto bail; |
109 | 110 |
110 val = PyDict_GetItem(dirs, key); | 111 val = PyDict_GetItem(dirs, key); |