summaryrefslogtreecommitdiffstats
path: root/Parser
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2002-08-16 17:01:09 (GMT)
committerGuido van Rossum <guido@python.org>2002-08-16 17:01:09 (GMT)
commit84b2bed4359e27070fe2eac4b464d4a1bc6e150d (patch)
tree0d1e50962419f5bf7e69bbc899b29a8d762e5d08 /Parser
parentc13f724af0a09d515efae57b902a1270b6aba4ac (diff)
downloadcpython-84b2bed4359e27070fe2eac4b464d4a1bc6e150d.zip
cpython-84b2bed4359e27070fe2eac4b464d4a1bc6e150d.tar.gz
cpython-84b2bed4359e27070fe2eac4b464d4a1bc6e150d.tar.bz2
Squash a few calls to the hideously expensive PyObject_CallObject(o,a)
-- replace then with slightly faster PyObject_Call(o,a,NULL). (The difference is that the latter requires a to be a tuple; the former allows other values and wraps them in a tuple if necessary; it involves two more levels of C function calls to accomplish all that.)
Diffstat (limited to 'Parser')
-rw-r--r--Parser/tokenizer.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/Parser/tokenizer.c b/Parser/tokenizer.c
index 7e7a370..4119c43 100644
--- a/Parser/tokenizer.c
+++ b/Parser/tokenizer.c
@@ -327,12 +327,16 @@ fp_readl(char *s, int size, struct tok_state *tok)
#ifndef Py_USING_UNICODE
/* In a non-Unicode built, this should never be called. */
Py_FatalError("fp_readl should not be called in this build.");
- return NULL;
+ return NULL; /* Keep compiler happy (not reachable) */
#else
PyObject* utf8;
PyObject* buf = tok->decoding_buffer;
if (buf == NULL) {
- buf = PyObject_CallObject(tok->decoding_readline, NULL);
+ PyObject *args = PyTuple_New(0);
+ if (args == NULL)
+ return error_ret(tok);
+ buf = PyObject_Call(tok->decoding_readline, args, NULL);
+ Py_DECREF(args);
if (buf == NULL)
return error_ret(tok);
} else {
@@ -464,7 +468,14 @@ decoding_feof(struct tok_state *tok)
} else {
PyObject* buf = tok->decoding_buffer;
if (buf == NULL) {
- buf = PyObject_CallObject(tok->decoding_readline, NULL);
+ PyObject *args = PyTuple_New(0);
+ if (args == NULL) {
+ error_ret(tok);
+ return 1;
+ }
+ buf = PyObject_Call(tok->decoding_readline,
+ args, NULL);
+ Py_DECREF(args);
if (buf == NULL) {
error_ret(tok);
return 1;