From 4a58707a340cacea6f8e6a82adfcc10a230e1185 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Tue, 19 Nov 2013 12:54:53 +0100 Subject: Add _PyUnicodeWriter_WriteASCIIString() function --- Python/formatter_unicode.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'Python') diff --git a/Python/formatter_unicode.c b/Python/formatter_unicode.c index e68087fd5a..0a3cc593d6 100644 --- a/Python/formatter_unicode.c +++ b/Python/formatter_unicode.c @@ -1053,24 +1053,24 @@ format_float_internal(PyObject *value, n_digits += 1; } - /* Since there is no unicode version of PyOS_double_to_string, - just use the 8 bit version and then convert to unicode. */ - unicode_tmp = _PyUnicode_FromASCII(buf, n_digits); - PyMem_Free(buf); - if (unicode_tmp == NULL) - goto done; - if (format->sign != '+' && format->sign != ' ' && format->width == -1 && format->type != 'n' && !format->thousands_separators) { /* Fast path */ - result = _PyUnicodeWriter_WriteStr(writer, unicode_tmp); - Py_DECREF(unicode_tmp); + result = _PyUnicodeWriter_WriteASCIIString(writer, buf, n_digits); + PyMem_Free(buf); return result; } + /* Since there is no unicode version of PyOS_double_to_string, + just use the 8 bit version and then convert to unicode. */ + unicode_tmp = _PyUnicode_FromASCII(buf, n_digits); + PyMem_Free(buf); + if (unicode_tmp == NULL) + goto done; + /* Is a sign character present in the output? If so, remember it and skip it */ index = 0; -- cgit v1.2.1