parsers: add an API to create a new presized dict
authorSiddharth Agarwal <sid0@fb.com>
Mon, 15 Jun 2015 22:41:30 -0700
changeset 25584 72b2711f12ea
parent 25583 ce64c9ab19f2
child 25585 868b7ee8b570
parsers: add an API to create a new presized dict
mercurial/parsers.c
--- a/mercurial/parsers.c	Mon Jun 15 22:37:33 2015 -0700
+++ b/mercurial/parsers.c	Mon Jun 15 22:41:30 2015 -0700
@@ -185,6 +185,16 @@
 	return _PyDict_NewPresized(((1 + expected_size) / 2) * 3);
 }
 
+static PyObject *dict_new_presized(PyObject *self, PyObject *args)
+{
+	Py_ssize_t expected_size;
+
+	if (!PyArg_ParseTuple(args, "n:make_presized_dict", &expected_size))
+		return NULL;
+
+	return _dict_new_presized(expected_size);
+}
+
 static PyObject *make_file_foldmap(PyObject *self, PyObject *args)
 {
 	PyObject *dmap, *spec_obj, *normcase_fallback;
@@ -2524,6 +2534,8 @@
 	{"parse_index2", parse_index2, METH_VARARGS, "parse a revlog index\n"},
 	{"asciilower", asciilower, METH_VARARGS, "lowercase an ASCII string\n"},
 	{"asciiupper", asciiupper, METH_VARARGS, "uppercase an ASCII string\n"},
+	{"dict_new_presized", dict_new_presized, METH_VARARGS,
+	 "construct a dict with an expected size\n"},
 	{"make_file_foldmap", make_file_foldmap, METH_VARARGS,
 	 "make file foldmap\n"},
 	{"encodedir", encodedir, METH_VARARGS, "encodedir a path\n"},