Cleanup: use braces in mathutils switch statements

Also move error checking before variable declarations.
This commit is contained in:
Campbell Barton
2025-09-16 14:50:41 +10:00
parent b2176bfdd7
commit 96d7c5c4cd
5 changed files with 138 additions and 84 deletions

View File

@@ -109,10 +109,6 @@ static PyObject *Quaternion_vectorcall(PyObject *type,
const size_t nargsf,
PyObject *kwnames)
{
double angle = 0.0f;
float quat[QUAT_SIZE];
unit_qt(quat);
if (UNLIKELY(kwnames && PyDict_Size(kwnames))) {
PyErr_SetString(PyExc_TypeError,
"mathutils.Quaternion(): "
@@ -120,10 +116,15 @@ static PyObject *Quaternion_vectorcall(PyObject *type,
return nullptr;
}
double angle = 0.0f;
float quat[QUAT_SIZE];
unit_qt(quat);
const size_t nargs = PyVectorcall_NARGS(nargsf);
switch (nargs) {
case 0:
case 0: {
break;
}
case 1: {
const int size = mathutils_array_parse(
quat, 3, QUAT_SIZE, args[0], "mathutils.Quaternion()");
@@ -950,22 +951,25 @@ static PyObject *Quaternion_richcmpr(PyObject *a, PyObject *b, int op)
}
switch (op) {
case Py_NE:
case Py_NE: {
ok = !ok;
ATTR_FALLTHROUGH;
case Py_EQ:
}
case Py_EQ: {
res = ok ? Py_False : Py_True;
break;
}
case Py_LT:
case Py_LE:
case Py_GT:
case Py_GE:
case Py_GE: {
res = Py_NotImplemented;
break;
default:
}
default: {
PyErr_BadArgument();
return nullptr;
}
}
return Py_NewRef(res);