use LIKELY/UNLIKELY macros for operations that run a lot.
This commit is contained in:
@@ -304,8 +304,9 @@ int Mathutils_RegisterCallback(Mathutils_Callback *cb)
|
||||
int _BaseMathObject_ReadCallback(BaseMathObject *self)
|
||||
{
|
||||
Mathutils_Callback *cb = mathutils_callbacks[self->cb_type];
|
||||
if (cb->get(self, self->cb_subtype) != -1)
|
||||
if (LIKELY(cb->get(self, self->cb_subtype) != -1)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!PyErr_Occurred()) {
|
||||
PyErr_Format(PyExc_RuntimeError,
|
||||
@@ -318,8 +319,9 @@ int _BaseMathObject_ReadCallback(BaseMathObject *self)
|
||||
int _BaseMathObject_WriteCallback(BaseMathObject *self)
|
||||
{
|
||||
Mathutils_Callback *cb = mathutils_callbacks[self->cb_type];
|
||||
if (cb->set(self, self->cb_subtype) != -1)
|
||||
if (LIKELY(cb->set(self, self->cb_subtype) != -1)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!PyErr_Occurred()) {
|
||||
PyErr_Format(PyExc_RuntimeError,
|
||||
@@ -332,8 +334,9 @@ int _BaseMathObject_WriteCallback(BaseMathObject *self)
|
||||
int _BaseMathObject_ReadIndexCallback(BaseMathObject *self, int index)
|
||||
{
|
||||
Mathutils_Callback *cb = mathutils_callbacks[self->cb_type];
|
||||
if (cb->get_index(self, self->cb_subtype, index) != -1)
|
||||
if (LIKELY(cb->get_index(self, self->cb_subtype, index) != -1)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!PyErr_Occurred()) {
|
||||
PyErr_Format(PyExc_RuntimeError,
|
||||
@@ -346,8 +349,9 @@ int _BaseMathObject_ReadIndexCallback(BaseMathObject *self, int index)
|
||||
int _BaseMathObject_WriteIndexCallback(BaseMathObject *self, int index)
|
||||
{
|
||||
Mathutils_Callback *cb = mathutils_callbacks[self->cb_type];
|
||||
if (cb->set_index(self, self->cb_subtype, index) != -1)
|
||||
if (LIKELY(cb->set_index(self, self->cb_subtype, index) != -1)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!PyErr_Occurred()) {
|
||||
PyErr_Format(PyExc_RuntimeError,
|
||||
|
||||
Reference in New Issue
Block a user