From: Victor Stinner Date: Thu, 8 Dec 2016 23:27:22 +0000 (+0100) Subject: modsupport: replace int with Py_ssize_t X-Git-Tag: v3.7.0a1~1804 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b551b6c9f083af7bffba224ca32e72175e7f8d54;p=python modsupport: replace int with Py_ssize_t Issue #28915: Py_ssize_t type is better for indexes. The compiler might emit more efficient code for i++. Py_ssize_t is the type of a PyTuple index for example. Replace also "int endchar" with "char endchar". --- diff --git a/Python/modsupport.c b/Python/modsupport.c index cb9a8a9389..eef79c460f 100644 --- a/Python/modsupport.c +++ b/Python/modsupport.c @@ -14,7 +14,7 @@ const char *_Py_PackageContext = NULL; /* Helper for mkvalue() to scan the length of a format */ static Py_ssize_t -countformat(const char *format, int endchar) +countformat(const char *format, char endchar) { Py_ssize_t count = 0; int level = 0; @@ -59,14 +59,14 @@ countformat(const char *format, int endchar) /* Generic function to create a value -- the inverse of getargs() */ /* After an original idea and first implementation by Steven Miale */ -static PyObject *do_mktuple(const char**, va_list *, int, Py_ssize_t, int); -static PyObject *do_mklist(const char**, va_list *, int, Py_ssize_t, int); -static PyObject *do_mkdict(const char**, va_list *, int, Py_ssize_t, int); +static PyObject *do_mktuple(const char**, va_list *, char, Py_ssize_t, int); +static PyObject *do_mklist(const char**, va_list *, char, Py_ssize_t, int); +static PyObject *do_mkdict(const char**, va_list *, char, Py_ssize_t, int); static PyObject *do_mkvalue(const char**, va_list *, int); static void -do_ignore(const char **p_format, va_list *p_va, int endchar, Py_ssize_t n, int flags) +do_ignore(const char **p_format, va_list *p_va, char endchar, Py_ssize_t n, int flags) { PyObject *v; Py_ssize_t i; @@ -99,7 +99,7 @@ do_ignore(const char **p_format, va_list *p_va, int endchar, Py_ssize_t n, int f } static PyObject * -do_mkdict(const char **p_format, va_list *p_va, int endchar, Py_ssize_t n, int flags) +do_mkdict(const char **p_format, va_list *p_va, char endchar, Py_ssize_t n, int flags) { PyObject *d; Py_ssize_t i; @@ -149,7 +149,7 @@ do_mkdict(const char **p_format, va_list *p_va, int endchar, Py_ssize_t n, int f } static PyObject * -do_mklist(const char **p_format, va_list *p_va, int endchar, Py_ssize_t n, int flags) +do_mklist(const char **p_format, va_list *p_va, char endchar, Py_ssize_t n, int flags) { PyObject *v; Py_ssize_t i; @@ -183,7 +183,7 @@ do_mklist(const char **p_format, va_list *p_va, int endchar, Py_ssize_t n, int f } static PyObject * -do_mktuple(const char **p_format, va_list *p_va, int endchar, Py_ssize_t n, int flags) +do_mktuple(const char **p_format, va_list *p_va, char endchar, Py_ssize_t n, int flags) { PyObject *v; Py_ssize_t i;