mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
Add _PyBytesWriter_WriteBytes() to factorize the code
This commit is contained in:
parent
ad7715891e
commit
ce179bf6ba
4 changed files with 35 additions and 16 deletions
|
@ -6706,14 +6706,12 @@ unicode_encode_ucs1(PyObject *unicode,
|
|||
|
||||
if (PyBytes_Check(repunicode)) {
|
||||
/* Directly copy bytes result to output. */
|
||||
repsize = PyBytes_Size(repunicode);
|
||||
|
||||
str = _PyBytesWriter_Prepare(&writer, str, repsize);
|
||||
str = _PyBytesWriter_WriteBytes(&writer, str,
|
||||
PyBytes_AS_STRING(repunicode),
|
||||
PyBytes_GET_SIZE(repunicode));
|
||||
if (str == NULL)
|
||||
goto onError;
|
||||
|
||||
memcpy(str, PyBytes_AsString(repunicode), repsize);
|
||||
str += repsize;
|
||||
pos = newpos;
|
||||
Py_DECREF(repunicode);
|
||||
break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue