From: Victor Stinner Date: Tue, 25 Jun 2019 23:49:32 +0000 (+0200) Subject: bpo-37388: Add PyUnicode_Decode(str, 0) fast-path (GH-14385) X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ed076ed467264b43ed01a8223ca65b133b590919;p=python bpo-37388: Add PyUnicode_Decode(str, 0) fast-path (GH-14385) Add a fast-path to PyUnicode_Decode() for size equals to 0. --- diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index b6f3d8f18c..51d314b61a 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -3354,6 +3354,10 @@ PyUnicode_Decode(const char *s, return NULL; } + if (size == 0) { + _Py_RETURN_UNICODE_EMPTY(); + } + if (encoding == NULL) { return PyUnicode_DecodeUTF8Stateful(s, size, errors, NULL); }