diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2011-11-13 03:11:37 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2011-11-13 03:11:37 (GMT) |
commit | 5c398e83951f1aafed9ecc998510ecdcdd486e70 (patch) | |
tree | c5b7de75e3c98586031e70389cf748139413a722 /Modules/_io | |
parent | c28e2e53ba1dd527ece0260785ed9bf7c5c38799 (diff) | |
download | cpython-5c398e83951f1aafed9ecc998510ecdcdd486e70.zip cpython-5c398e83951f1aafed9ecc998510ecdcdd486e70.tar.gz cpython-5c398e83951f1aafed9ecc998510ecdcdd486e70.tar.bz2 |
Restore performance of special casings for utf-16 and utf-32 in TextIOWrapper
Diffstat (limited to 'Modules/_io')
-rw-r--r-- | Modules/_io/textio.c | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/Modules/_io/textio.c b/Modules/_io/textio.c index 590a9e6..a356655 100644 --- a/Modules/_io/textio.c +++ b/Modules/_io/textio.c @@ -725,17 +725,15 @@ ascii_encode(textio *self, PyObject *text) static PyObject * utf16be_encode(textio *self, PyObject *text) { - return PyUnicode_EncodeUTF16(PyUnicode_AS_UNICODE(text), - PyUnicode_GET_SIZE(text), - PyBytes_AS_STRING(self->errors), 1); + return _PyUnicode_EncodeUTF16(text, + PyBytes_AS_STRING(self->errors), 1); } static PyObject * utf16le_encode(textio *self, PyObject *text) { - return PyUnicode_EncodeUTF16(PyUnicode_AS_UNICODE(text), - PyUnicode_GET_SIZE(text), - PyBytes_AS_STRING(self->errors), -1); + return _PyUnicode_EncodeUTF16(text, + PyBytes_AS_STRING(self->errors), -1); } static PyObject * @@ -749,25 +747,22 @@ utf16_encode(textio *self, PyObject *text) return utf16le_encode(self, text); #endif } - return PyUnicode_EncodeUTF16(PyUnicode_AS_UNICODE(text), - PyUnicode_GET_SIZE(text), - PyBytes_AS_STRING(self->errors), 0); + return _PyUnicode_EncodeUTF16(text, + PyBytes_AS_STRING(self->errors), 0); } static PyObject * utf32be_encode(textio *self, PyObject *text) { - return PyUnicode_EncodeUTF32(PyUnicode_AS_UNICODE(text), - PyUnicode_GET_SIZE(text), - PyBytes_AS_STRING(self->errors), 1); + return _PyUnicode_EncodeUTF32(text, + PyBytes_AS_STRING(self->errors), 1); } static PyObject * utf32le_encode(textio *self, PyObject *text) { - return PyUnicode_EncodeUTF32(PyUnicode_AS_UNICODE(text), - PyUnicode_GET_SIZE(text), - PyBytes_AS_STRING(self->errors), -1); + return _PyUnicode_EncodeUTF32(text, + PyBytes_AS_STRING(self->errors), -1); } static PyObject * @@ -781,9 +776,8 @@ utf32_encode(textio *self, PyObject *text) return utf32le_encode(self, text); #endif } - return PyUnicode_EncodeUTF32(PyUnicode_AS_UNICODE(text), - PyUnicode_GET_SIZE(text), - PyBytes_AS_STRING(self->errors), 0); + return _PyUnicode_EncodeUTF32(text, + PyBytes_AS_STRING(self->errors), 0); } static PyObject * |