mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
Replace PyObject_CallFunction() with fastcall
Replace PyObject_CallFunction(func, "O", arg) and PyObject_CallFunction(func, "O", arg, NULL) with _PyObject_CallArg1(func, arg) Replace PyObject_CallFunction(func, NULL) with _PyObject_CallNoArg(func) _PyObject_CallNoArg() and _PyObject_CallArg1() are simpler and don't allocate memory on the C stack.
This commit is contained in:
parent
842cfff321
commit
4778eab1f2
8 changed files with 13 additions and 13 deletions
|
@ -538,7 +538,7 @@ deque_copy(PyObject *deque)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (old_deque->maxlen < 0)
|
if (old_deque->maxlen < 0)
|
||||||
return PyObject_CallFunction((PyObject *)(Py_TYPE(deque)), "O", deque, NULL);
|
return _PyObject_CallArg1((PyObject *)(Py_TYPE(deque)), deque);
|
||||||
else
|
else
|
||||||
return PyObject_CallFunction((PyObject *)(Py_TYPE(deque)), "Oi",
|
return PyObject_CallFunction((PyObject *)(Py_TYPE(deque)), "Oi",
|
||||||
deque, old_deque->maxlen, NULL);
|
deque, old_deque->maxlen, NULL);
|
||||||
|
|
|
@ -2831,7 +2831,7 @@ expat_set_error(enum XML_Error error_code, Py_ssize_t line, Py_ssize_t column,
|
||||||
if (errmsg == NULL)
|
if (errmsg == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
error = PyObject_CallFunction(st->parseerror_obj, "O", errmsg);
|
error = _PyObject_CallArg1(st->parseerror_obj, errmsg);
|
||||||
Py_DECREF(errmsg);
|
Py_DECREF(errmsg);
|
||||||
if (!error)
|
if (!error)
|
||||||
return;
|
return;
|
||||||
|
@ -2894,7 +2894,7 @@ expat_default_handler(XMLParserObject* self, const XML_Char* data_in,
|
||||||
(TreeBuilderObject*) self->target, value
|
(TreeBuilderObject*) self->target, value
|
||||||
);
|
);
|
||||||
else if (self->handle_data)
|
else if (self->handle_data)
|
||||||
res = PyObject_CallFunction(self->handle_data, "O", value);
|
res = _PyObject_CallArg1(self->handle_data, value);
|
||||||
else
|
else
|
||||||
res = NULL;
|
res = NULL;
|
||||||
Py_XDECREF(res);
|
Py_XDECREF(res);
|
||||||
|
@ -3004,7 +3004,7 @@ expat_data_handler(XMLParserObject* self, const XML_Char* data_in,
|
||||||
/* shortcut */
|
/* shortcut */
|
||||||
res = treebuilder_handle_data((TreeBuilderObject*) self->target, data);
|
res = treebuilder_handle_data((TreeBuilderObject*) self->target, data);
|
||||||
else if (self->handle_data)
|
else if (self->handle_data)
|
||||||
res = PyObject_CallFunction(self->handle_data, "O", data);
|
res = _PyObject_CallArg1(self->handle_data, data);
|
||||||
else
|
else
|
||||||
res = NULL;
|
res = NULL;
|
||||||
|
|
||||||
|
@ -3031,7 +3031,7 @@ expat_end_handler(XMLParserObject* self, const XML_Char* tag_in)
|
||||||
else if (self->handle_end) {
|
else if (self->handle_end) {
|
||||||
tag = makeuniversal(self, tag_in);
|
tag = makeuniversal(self, tag_in);
|
||||||
if (tag) {
|
if (tag) {
|
||||||
res = PyObject_CallFunction(self->handle_end, "O", tag);
|
res = _PyObject_CallArg1(self->handle_end, tag);
|
||||||
Py_DECREF(tag);
|
Py_DECREF(tag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3090,7 +3090,7 @@ expat_comment_handler(XMLParserObject* self, const XML_Char* comment_in)
|
||||||
if (self->handle_comment) {
|
if (self->handle_comment) {
|
||||||
comment = PyUnicode_DecodeUTF8(comment_in, strlen(comment_in), "strict");
|
comment = PyUnicode_DecodeUTF8(comment_in, strlen(comment_in), "strict");
|
||||||
if (comment) {
|
if (comment) {
|
||||||
res = PyObject_CallFunction(self->handle_comment, "O", comment);
|
res = _PyObject_CallArg1(self->handle_comment, comment);
|
||||||
Py_XDECREF(res);
|
Py_XDECREF(res);
|
||||||
Py_DECREF(comment);
|
Py_DECREF(comment);
|
||||||
}
|
}
|
||||||
|
|
|
@ -119,7 +119,7 @@ set_error(xmlparseobject *self, enum XML_Error code)
|
||||||
XML_ErrorString(code), lineno, column);
|
XML_ErrorString(code), lineno, column);
|
||||||
if (buffer == NULL)
|
if (buffer == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
err = PyObject_CallFunction(ErrorObject, "O", buffer);
|
err = _PyObject_CallArg1(ErrorObject, buffer);
|
||||||
Py_DECREF(buffer);
|
Py_DECREF(buffer);
|
||||||
if ( err != NULL
|
if ( err != NULL
|
||||||
&& set_error_attr(err, "code", code)
|
&& set_error_attr(err, "code", code)
|
||||||
|
|
|
@ -868,7 +868,7 @@ on_hook(PyObject *func)
|
||||||
int result = 0;
|
int result = 0;
|
||||||
if (func != NULL) {
|
if (func != NULL) {
|
||||||
PyObject *r;
|
PyObject *r;
|
||||||
r = PyObject_CallFunction(func, NULL);
|
r = _PyObject_CallNoArg(func);
|
||||||
if (r == NULL)
|
if (r == NULL)
|
||||||
goto error;
|
goto error;
|
||||||
if (r == Py_None)
|
if (r == Py_None)
|
||||||
|
|
|
@ -1341,7 +1341,7 @@ async_gen_init_hooks(PyAsyncGenObject *o)
|
||||||
PyObject *res;
|
PyObject *res;
|
||||||
|
|
||||||
Py_INCREF(firstiter);
|
Py_INCREF(firstiter);
|
||||||
res = PyObject_CallFunction(firstiter, "O", o);
|
res = _PyObject_CallArg1(firstiter, o);
|
||||||
Py_DECREF(firstiter);
|
Py_DECREF(firstiter);
|
||||||
if (res == NULL) {
|
if (res == NULL) {
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -476,7 +476,7 @@ warn_explicit(PyObject *category, PyObject *message,
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
text = message;
|
text = message;
|
||||||
message = PyObject_CallFunction(category, "O", message);
|
message = _PyObject_CallArg1(category, message);
|
||||||
if (message == NULL)
|
if (message == NULL)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
|
@ -284,7 +284,7 @@ PyObject *codec_makeincrementalcodec(PyObject *codec_info,
|
||||||
if (errors)
|
if (errors)
|
||||||
ret = PyObject_CallFunction(inccodec, "s", errors);
|
ret = PyObject_CallFunction(inccodec, "s", errors);
|
||||||
else
|
else
|
||||||
ret = PyObject_CallFunction(inccodec, NULL);
|
ret = _PyObject_CallNoArg(inccodec);
|
||||||
Py_DECREF(inccodec);
|
Py_DECREF(inccodec);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -322,7 +322,7 @@ PyObject *codec_getstreamcodec(const char *encoding,
|
||||||
if (errors != NULL)
|
if (errors != NULL)
|
||||||
streamcodec = PyObject_CallFunction(codeccls, "Os", stream, errors);
|
streamcodec = PyObject_CallFunction(codeccls, "Os", stream, errors);
|
||||||
else
|
else
|
||||||
streamcodec = PyObject_CallFunction(codeccls, "O", stream);
|
streamcodec = _PyObject_CallArg1(codeccls, stream);
|
||||||
Py_DECREF(codecs);
|
Py_DECREF(codecs);
|
||||||
return streamcodec;
|
return streamcodec;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1274,7 +1274,7 @@ r_object(RFILE *p)
|
||||||
|
|
||||||
if (n == 0 && type == TYPE_FROZENSET) {
|
if (n == 0 && type == TYPE_FROZENSET) {
|
||||||
/* call frozenset() to get the empty frozenset singleton */
|
/* call frozenset() to get the empty frozenset singleton */
|
||||||
v = PyObject_CallFunction((PyObject*)&PyFrozenSet_Type, NULL);
|
v = _PyObject_CallNoArg((PyObject*)&PyFrozenSet_Type);
|
||||||
if (v == NULL)
|
if (v == NULL)
|
||||||
break;
|
break;
|
||||||
R_REF(v);
|
R_REF(v);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue