diff options
author | Neal Norwitz <nnorwitz@gmail.com> | 2002-06-13 21:32:44 (GMT) |
---|---|---|
committer | Neal Norwitz <nnorwitz@gmail.com> | 2002-06-13 21:32:44 (GMT) |
commit | 51290d369d7ef7bc9dec6a0082e3aa4f5e434d31 (patch) | |
tree | 704799da87a9f58e441717c2713c496552a58905 | |
parent | 20e72130c4054bb59aa3fe514522065003b0ed89 (diff) | |
download | cpython-51290d369d7ef7bc9dec6a0082e3aa4f5e434d31.zip cpython-51290d369d7ef7bc9dec6a0082e3aa4f5e434d31.tar.gz cpython-51290d369d7ef7bc9dec6a0082e3aa4f5e434d31.tar.bz2 |
SF # 561244 Micro optimizations
Cleanup code a bit and return as early as possible.
-rw-r--r-- | Objects/object.c | 8 |
1 files changed, 3 insertions, 5 deletions
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 @@ PyObject_IsTrue(PyObject *v) { 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 @@ PyObject_IsTrue(PyObject *v) 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' |