SF # 561244 Micro optimizations
Cleanup code a bit and return as early as possible.
diff --git a/Objects/object.c b/Objects/object.c
index 6e72c24..b196d14 100644
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -1435,7 +1435,7 @@
{
int res;
if (v == Py_None)
- res = 0;
+ return 0;
else if (v->ob_type->tp_as_number != NULL &&
v->ob_type->tp_as_number->nb_nonzero != NULL)
res = (*v->ob_type->tp_as_number->nb_nonzero)(v);
@@ -1446,10 +1446,8 @@
v->ob_type->tp_as_sequence->sq_length != NULL)
res = (*v->ob_type->tp_as_sequence->sq_length)(v);
else
- res = 1;
- if (res > 0)
- res = 1;
- return res;
+ return 1;
+ return (res > 0) ? 1 : res;
}
/* equivalent of 'not v'