summaryrefslogtreecommitdiffstats
path: root/Objects/unicodeobject.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2019-06-25 23:49:32 (GMT)
committerGitHub <noreply@github.com>2019-06-25 23:49:32 (GMT)
commited076ed467264b43ed01a8223ca65b133b590919 (patch)
tree480845a2680f6e36fd0f70bbf4e51e8f8d81134c /Objects/unicodeobject.c
parent22eb689cf3de7972a2789db3ad01a86949508ab7 (diff)
downloadcpython-ed076ed467264b43ed01a8223ca65b133b590919.zip
cpython-ed076ed467264b43ed01a8223ca65b133b590919.tar.gz
cpython-ed076ed467264b43ed01a8223ca65b133b590919.tar.bz2
bpo-37388: Add PyUnicode_Decode(str, 0) fast-path (GH-14385)
Add a fast-path to PyUnicode_Decode() for size equals to 0.
Diffstat (limited to 'Objects/unicodeobject.c')
-rw-r--r--Objects/unicodeobject.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index b6f3d8f..51d314b 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);
}