From 9b6c60cbce4ac45e8ccd7934babff465e9769509 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Mon, 13 Nov 2017 21:23:48 +0200 Subject: bpo-31979: Simplify transforming decimals to ASCII (#4336) in int(), float() and complex() parsers. This also speeds up parsing non-ASCII numbers by around 20%. --- Objects/floatobject.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'Objects/floatobject.c') diff --git a/Objects/floatobject.c b/Objects/floatobject.c index 8d7a55ac6f..47a174c241 100644 --- a/Objects/floatobject.c +++ b/Objects/floatobject.c @@ -176,11 +176,10 @@ PyFloat_FromString(PyObject *v) s_buffer = _PyUnicode_TransformDecimalAndSpaceToASCII(v); if (s_buffer == NULL) return NULL; + assert(PyUnicode_IS_ASCII(s_buffer)); + /* Simply get a pointer to existing ASCII characters. */ s = PyUnicode_AsUTF8AndSize(s_buffer, &len); - if (s == NULL) { - Py_DECREF(s_buffer); - return NULL; - } + assert(s != NULL); } else if (PyBytes_Check(v)) { s = PyBytes_AS_STRING(v); -- cgit v1.2.1