Skip to content

Commit

Permalink
Replace Py_RETURN_TRUE/FALSE
Browse files Browse the repository at this point in the history
  • Loading branch information
JCGoran committed Jan 10, 2025
1 parent 6031d38 commit 638ff3f
Showing 1 changed file with 5 additions and 18 deletions.
23 changes: 5 additions & 18 deletions src/nrnpython/nrnpy_hoc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2386,10 +2386,7 @@ PyObject* nrn_ptr_richcmp(void* self_ptr, void* other_ptr, int op) {
result = self_ptr >= other_ptr;
break;
}
if (result) {
Py_RETURN_TRUE;
}
Py_RETURN_FALSE;
return PyBool_FromLong(result);
}

// TODO: unfortunately, this duplicates code from hocobj_same; consolidate?
Expand Down Expand Up @@ -2440,20 +2437,14 @@ static PyObject* hocobj_richcmp(PyHocObject* self, PyObject* other, int op) {
break;
}
if (self->nindex_ != pyhoc_other->nindex_ || self->sym_ != pyhoc_other->sym_) {
if (op == Py_NE) {
Py_RETURN_TRUE;
}
Py_RETURN_FALSE;
return PyBool_FromLong(op == Py_NE);
}
for (int i = 0; i < self->nindex_; i++) {
if (self->indices_[i] != pyhoc_other->indices_[i]) {
are_equal = false;
}
}
if (are_equal == (op == Py_EQ)) {
Py_RETURN_TRUE;
}
Py_RETURN_FALSE;
return PyBool_FromLong(are_equal == (op == Py_EQ));
default:
other_ptr = pyhoc_other->ho_;
}
Expand All @@ -2474,12 +2465,8 @@ static PyObject* hocobj_richcmp(PyHocObject* self, PyObject* other, int op) {
static PyObject* hocobj_same(PyHocObject* pself, PyObject* args) {
PyObject* po;
if (PyArg_ParseTuple(args, "O", &po)) {
if (PyObject_TypeCheck(po, hocobject_type)) {
if (((PyHocObject*) po)->ho_ == pself->ho_) {
Py_RETURN_TRUE;
}
}
Py_RETURN_FALSE;
return PyBool_FromLong(PyObject_TypeCheck(po, hocobject_type) &&
((PyHocObject*) po)->ho_ == pself->ho_);
}
return NULL;
}
Expand Down

0 comments on commit 638ff3f

Please sign in to comment.