##// END OF EJS Templates
revlog: remove unnecessary output parameter from node_check()...
Martin von Zweigbergk -
r38855:49628742 default
parent child Browse files
Show More
@@ -264,11 +264,12 b' static const char *index_node_existing(i'
264
264
265 static int nt_insert(indexObject *self, const char *node, int rev);
265 static int nt_insert(indexObject *self, const char *node, int rev);
266
266
267 static int node_check(PyObject *obj, char **node, Py_ssize_t *nodelen)
267 static int node_check(PyObject *obj, char **node)
268 {
268 {
269 if (PyBytes_AsStringAndSize(obj, node, nodelen) == -1)
269 Py_ssize_t nodelen;
270 if (PyBytes_AsStringAndSize(obj, node, &nodelen) == -1)
270 return -1;
271 return -1;
271 if (*nodelen == 20)
272 if (nodelen == 20)
272 return 0;
273 return 0;
273 PyErr_SetString(PyExc_ValueError, "20-byte hash required");
274 PyErr_SetString(PyExc_ValueError, "20-byte hash required");
274 return -1;
275 return -1;
@@ -279,7 +280,7 b' static PyObject *index_insert(indexObjec'
279 PyObject *obj;
280 PyObject *obj;
280 char *node;
281 char *node;
281 int index;
282 int index;
282 Py_ssize_t len, nodelen;
283 Py_ssize_t len;
283
284
284 if (!PyArg_ParseTuple(args, "iO", &index, &obj))
285 if (!PyArg_ParseTuple(args, "iO", &index, &obj))
285 return NULL;
286 return NULL;
@@ -289,7 +290,7 b' static PyObject *index_insert(indexObjec'
289 return NULL;
290 return NULL;
290 }
291 }
291
292
292 if (node_check(PyTuple_GET_ITEM(obj, 7), &node, &nodelen) == -1)
293 if (node_check(PyTuple_GET_ITEM(obj, 7), &node) == -1)
293 return NULL;
294 return NULL;
294
295
295 len = index_length(self);
296 len = index_length(self);
@@ -1214,15 +1215,14 b' cleanup:'
1214 static PyObject *index_getitem(indexObject *self, PyObject *value)
1215 static PyObject *index_getitem(indexObject *self, PyObject *value)
1215 {
1216 {
1216 char *node;
1217 char *node;
1217 Py_ssize_t nodelen;
1218 int rev;
1218 int rev;
1219
1219
1220 if (PyInt_Check(value))
1220 if (PyInt_Check(value))
1221 return index_get(self, PyInt_AS_LONG(value));
1221 return index_get(self, PyInt_AS_LONG(value));
1222
1222
1223 if (node_check(value, &node, &nodelen) == -1)
1223 if (node_check(value, &node) == -1)
1224 return NULL;
1224 return NULL;
1225 rev = index_find_node(self, node, nodelen);
1225 rev = index_find_node(self, node, 20);
1226 if (rev >= -1)
1226 if (rev >= -1)
1227 return PyInt_FromLong(rev);
1227 return PyInt_FromLong(rev);
1228 if (rev == -2)
1228 if (rev == -2)
@@ -1360,14 +1360,13 b' static PyObject *index_partialmatch(inde'
1360
1360
1361 static PyObject *index_shortest(indexObject *self, PyObject *args)
1361 static PyObject *index_shortest(indexObject *self, PyObject *args)
1362 {
1362 {
1363 Py_ssize_t nodelen;
1364 PyObject *val;
1363 PyObject *val;
1365 char *node;
1364 char *node;
1366 int length;
1365 int length;
1367
1366
1368 if (!PyArg_ParseTuple(args, "O", &val))
1367 if (!PyArg_ParseTuple(args, "O", &val))
1369 return NULL;
1368 return NULL;
1370 if (node_check(val, &node, &nodelen) == -1)
1369 if (node_check(val, &node) == -1)
1371 return NULL;
1370 return NULL;
1372
1371
1373 self->ntlookups++;
1372 self->ntlookups++;
@@ -1383,16 +1382,15 b' static PyObject *index_shortest(indexObj'
1383
1382
1384 static PyObject *index_m_get(indexObject *self, PyObject *args)
1383 static PyObject *index_m_get(indexObject *self, PyObject *args)
1385 {
1384 {
1386 Py_ssize_t nodelen;
1387 PyObject *val;
1385 PyObject *val;
1388 char *node;
1386 char *node;
1389 int rev;
1387 int rev;
1390
1388
1391 if (!PyArg_ParseTuple(args, "O", &val))
1389 if (!PyArg_ParseTuple(args, "O", &val))
1392 return NULL;
1390 return NULL;
1393 if (node_check(val, &node, &nodelen) == -1)
1391 if (node_check(val, &node) == -1)
1394 return NULL;
1392 return NULL;
1395 rev = index_find_node(self, node, nodelen);
1393 rev = index_find_node(self, node, 20);
1396 if (rev == -3)
1394 if (rev == -3)
1397 return NULL;
1395 return NULL;
1398 if (rev == -2)
1396 if (rev == -2)
@@ -1403,17 +1401,16 b' static PyObject *index_m_get(indexObject'
1403 static int index_contains(indexObject *self, PyObject *value)
1401 static int index_contains(indexObject *self, PyObject *value)
1404 {
1402 {
1405 char *node;
1403 char *node;
1406 Py_ssize_t nodelen;
1407
1404
1408 if (PyInt_Check(value)) {
1405 if (PyInt_Check(value)) {
1409 long rev = PyInt_AS_LONG(value);
1406 long rev = PyInt_AS_LONG(value);
1410 return rev >= -1 && rev < index_length(self);
1407 return rev >= -1 && rev < index_length(self);
1411 }
1408 }
1412
1409
1413 if (node_check(value, &node, &nodelen) == -1)
1410 if (node_check(value, &node) == -1)
1414 return -1;
1411 return -1;
1415
1412
1416 switch (index_find_node(self, node, nodelen)) {
1413 switch (index_find_node(self, node, 20)) {
1417 case -3:
1414 case -3:
1418 return -1;
1415 return -1;
1419 case -2:
1416 case -2:
@@ -1897,13 +1894,12 b' static int index_assign_subscript(indexO'
1897 PyObject *value)
1894 PyObject *value)
1898 {
1895 {
1899 char *node;
1896 char *node;
1900 Py_ssize_t nodelen;
1901 long rev;
1897 long rev;
1902
1898
1903 if (PySlice_Check(item) && value == NULL)
1899 if (PySlice_Check(item) && value == NULL)
1904 return index_slice_del(self, item);
1900 return index_slice_del(self, item);
1905
1901
1906 if (node_check(item, &node, &nodelen) == -1)
1902 if (node_check(item, &node) == -1)
1907 return -1;
1903 return -1;
1908
1904
1909 if (value == NULL)
1905 if (value == NULL)
General Comments 0
You need to be logged in to leave comments. Login now