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

Add a fast-path to PyUnicode_Decode() for size equals to 0.
This commit is contained in:
Victor Stinner 2019-06-26 01:49:32 +02:00 committed by GitHub
parent 22eb689cf3
commit ed076ed467
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 0 deletions

View File

@ -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);
}