[Python-checkins] r68386 - in sandbox/trunk/io-c: _iomodule.h _textio.c io.c

antoine.pitrou python-checkins at python.org
Thu Jan 8 00:40:51 CET 2009


Author: antoine.pitrou
Date: Thu Jan  8 00:40:51 2009
New Revision: 68386

Log:
Intern some more method names.



Modified:
   sandbox/trunk/io-c/_iomodule.h
   sandbox/trunk/io-c/_textio.c
   sandbox/trunk/io-c/io.c

Modified: sandbox/trunk/io-c/_iomodule.h
==============================================================================
--- sandbox/trunk/io-c/_iomodule.h	(original)
+++ sandbox/trunk/io-c/_iomodule.h	Thu Jan  8 00:40:51 2009
@@ -52,8 +52,11 @@
 
 extern PyObject *_PyIO_str_close;
 extern PyObject *_PyIO_str_closed;
+extern PyObject *_PyIO_str_decode;
+extern PyObject *_PyIO_str_encode;
 extern PyObject *_PyIO_str_fileno;
 extern PyObject *_PyIO_str_flush;
+extern PyObject *_PyIO_str_getstate;
 extern PyObject *_PyIO_str_isatty;
 extern PyObject *_PyIO_str_read;
 extern PyObject *_PyIO_str_readable;

Modified: sandbox/trunk/io-c/_textio.c
==============================================================================
--- sandbox/trunk/io-c/_textio.c	(original)
+++ sandbox/trunk/io-c/_textio.c	Thu Jan  8 00:40:51 2009
@@ -116,7 +116,8 @@
     }
 
     /* decode input (with the eventual \r from a previous pass) */
-    output = PyObject_CallMethod(self->decoder, "decode", "Oi", input, final);
+    output = PyObject_CallMethodObjArgs(self->decoder, _PyIO_str_decode,
+                                        input, final ? Py_True : Py_False, NULL);
     if (output == NULL)
         return NULL;
 
@@ -257,7 +258,8 @@
 static PyObject *
 IncrementalNewlineDecoder_getstate(PyNewLineDecoderObject *self, PyObject *args)
 {
-    PyObject *state = PyObject_CallMethod(self->decoder, "getstate", NULL);
+    PyObject *state = PyObject_CallMethodObjArgs(self->decoder,
+                                                 _PyIO_str_getstate, NULL);
     PyObject *buffer;
     unsigned PY_LONG_LONG flag;
 
@@ -771,7 +773,8 @@
          * where the decoder's input buffer is empty.
          */
 
-        PyObject *state = PyObject_CallMethod(self->decoder, "getstate", NULL);
+        PyObject *state = PyObject_CallMethodObjArgs(self->decoder,
+                                                     _PyIO_str_getstate, NULL);
         if (state == NULL)
             return -1;
         /* Given this, we know there was a valid snapshot point
@@ -1372,7 +1375,8 @@
     /* Starting from the snapshot position, we will walk the decoder
      * forward until it gives us enough decoded characters.
      */
-    saved_state = PyObject_CallMethod(self->decoder, "getstate", NULL);
+    saved_state = PyObject_CallMethodObjArgs(self->decoder,
+                                             _PyIO_str_getstate, NULL);
     if (saved_state == NULL)
         goto fail;
 
@@ -1407,7 +1411,8 @@
 
         cookie.bytes_to_feed += 1;
 
-        state = PyObject_CallMethod(self->decoder, "getstate", NULL);
+        state = PyObject_CallMethodObjArgs(self->decoder,
+                                           _PyIO_str_getstate, NULL);
         if (state == NULL)
             goto fail;
         if (!PyArg_Parse(state, "(y#i)", &dec_buffer, &dec_buffer_len, &dec_flags)) {

Modified: sandbox/trunk/io-c/io.c
==============================================================================
--- sandbox/trunk/io-c/io.c	(original)
+++ sandbox/trunk/io-c/io.c	Thu Jan  8 00:40:51 2009
@@ -16,8 +16,11 @@
 
 PyObject *_PyIO_str_close;
 PyObject *_PyIO_str_closed;
+PyObject *_PyIO_str_decode;
+PyObject *_PyIO_str_encode;
 PyObject *_PyIO_str_fileno;
 PyObject *_PyIO_str_flush;
+PyObject *_PyIO_str_getstate;
 PyObject *_PyIO_str_isatty;
 PyObject *_PyIO_str_read;
 PyObject *_PyIO_str_readable;
@@ -629,10 +632,16 @@
         goto fail;
     if (!(_PyIO_str_closed = PyUnicode_InternFromString("closed")))
         goto fail;
+    if (!(_PyIO_str_decode = PyUnicode_InternFromString("decode")))
+        goto fail;
+    if (!(_PyIO_str_encode = PyUnicode_InternFromString("encode")))
+        goto fail;
     if (!(_PyIO_str_fileno = PyUnicode_InternFromString("fileno")))
         goto fail;
     if (!(_PyIO_str_flush = PyUnicode_InternFromString("flush")))
         goto fail;
+    if (!(_PyIO_str_getstate = PyUnicode_InternFromString("getstate")))
+        goto fail;
     if (!(_PyIO_str_isatty = PyUnicode_InternFromString("isatty")))
         goto fail;
     if (!(_PyIO_str_read = PyUnicode_InternFromString("read")))


More information about the Python-checkins mailing list