Skip to content

Commit ed076ed

Browse files
authored
bpo-37388: Add PyUnicode_Decode(str, 0) fast-path (GH-14385)
Add a fast-path to PyUnicode_Decode() for size equals to 0.
1 parent 22eb689 commit ed076ed

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Objects/unicodeobject.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3354,6 +3354,10 @@ PyUnicode_Decode(const char *s,
33543354
return NULL;
33553355
}
33563356

3357+
if (size == 0) {
3358+
_Py_RETURN_UNICODE_EMPTY();
3359+
}
3360+
33573361
if (encoding == NULL) {
33583362
return PyUnicode_DecodeUTF8Stateful(s, size, errors, NULL);
33593363
}

0 commit comments

Comments
 (0)