Add _PyBytesWriter_WriteBytes() to factorize the code

This commit is contained in:
Victor Stinner 2015-10-09 12:57:22 +02:00
parent ad7715891e
commit ce179bf6ba
4 changed files with 35 additions and 16 deletions

View file

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