]> granicus.if.org Git - python/commitdiff
Fast path for IncrementalNewlineDecoder.decode() in io.TextIOWrapper.read(-1)
authorVictor Stinner <victor.stinner@haypocalc.com>
Wed, 25 May 2011 20:01:33 +0000 (22:01 +0200)
committerVictor Stinner <victor.stinner@haypocalc.com>
Wed, 25 May 2011 20:01:33 +0000 (22:01 +0200)
Copy/paste code from textiowrapper_read_chunk().

Modules/_io/textio.c

index 35bd922b8eb9ac2d681777104af5499ead5a5c94..70d062b16f13c1769facfff79d3295e75b958690 100644 (file)
@@ -1513,8 +1513,13 @@ textiowrapper_read(textio *self, PyObject *args)
         PyObject *decoded;
         if (bytes == NULL)
             goto fail;
-        decoded = PyObject_CallMethodObjArgs(self->decoder, _PyIO_str_decode,
-                                             bytes, Py_True, NULL);
+
+        if (Py_TYPE(self->decoder) == &PyIncrementalNewlineDecoder_Type)
+            decoded = _PyIncrementalNewlineDecoder_decode(self->decoder,
+                                                          bytes, 1);
+        else
+            decoded = PyObject_CallMethodObjArgs(
+                self->decoder, _PyIO_str_decode, bytes, Py_True, NULL);
         Py_DECREF(bytes);
         if (decoded == NULL)
             goto fail;