Avoid dict lookups when calling python callbacks
This commit is contained in:
parent
6698712b44
commit
b20367b888
@ -330,7 +330,7 @@ render(ChildMonitor *self, double *timeout) {
|
|||||||
double now = monotonic();
|
double now = monotonic();
|
||||||
double time_since_last_render = now - last_render_at;
|
double time_since_last_render = now - last_render_at;
|
||||||
if (time_since_last_render > self->repaint_delay) {
|
if (time_since_last_render > self->repaint_delay) {
|
||||||
ret = PyObject_CallObject(self->render_func, NULL);
|
ret = PyObject_CallFunctionObjArgs(self->render_func, NULL);
|
||||||
if (ret == NULL) return false;
|
if (ret == NULL) return false;
|
||||||
else Py_DECREF(ret);
|
else Py_DECREF(ret);
|
||||||
glfwSwapBuffers(glfw_window_id);
|
glfwSwapBuffers(glfw_window_id);
|
||||||
|
|||||||
@ -189,7 +189,7 @@ timers_call(Timers *self) {
|
|||||||
for (i = 0, j = 0; i < self->count; i++) {
|
for (i = 0, j = 0; i < self->count; i++) {
|
||||||
if (self->events[i].at <= now) { // expired, call it
|
if (self->events[i].at <= now) { // expired, call it
|
||||||
if (self->events[i].callback != Py_None) {
|
if (self->events[i].callback != Py_None) {
|
||||||
PyObject *ret = PyObject_CallObject(self->events[i].callback, self->events[i].args);
|
PyObject *ret = self->events[i].args ? PyObject_CallObject(self->events[i].callback, self->events[i].args) : PyObject_CallFunctionObjArgs(self->events[i].callback, NULL);
|
||||||
if (ret == NULL) PyErr_Print();
|
if (ret == NULL) PyErr_Print();
|
||||||
else Py_DECREF(ret);
|
else Py_DECREF(ret);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user