[Python-checkins] bpo-37388: Add PyUnicode_Decode(str, 0) fast-path (GH-14385)

Victor Stinner webhook-mailer at python.org
Tue Jun 25 19:49:36 EDT 2019


https://github.com/python/cpython/commit/ed076ed467264b43ed01a8223ca65b133b590919
commit: ed076ed467264b43ed01a8223ca65b133b590919
branch: master
author: Victor Stinner <vstinner at redhat.com>
committer: GitHub <noreply at github.com>
date: 2019-06-26T01:49:32+02:00
summary:

bpo-37388: Add PyUnicode_Decode(str, 0) fast-path (GH-14385)

Add a fast-path to PyUnicode_Decode() for size equals to 0.

files:
M Objects/unicodeobject.c

diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index b6f3d8f18c4c..51d314b61a52 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);
     }



More information about the Python-checkins mailing list