summaryrefslogtreecommitdiffstatshomepage
path: root/py/runtime.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-01-30 10:05:33 +0000
committerDamien George <damien.p.george@gmail.com>2014-01-30 10:05:33 +0000
commit09a0c64bce93f5ebcea82e81b4b07ddd7ff76cc7 (patch)
tree5083bfffe18f07af6a3030199914459684a89a09 /py/runtime.c
parentb25711ea8fdc1588b5a69f7d0941de09b50fa28c (diff)
downloadmicropython-09a0c64bce93f5ebcea82e81b4b07ddd7ff76cc7.tar.gz
micropython-09a0c64bce93f5ebcea82e81b4b07ddd7ff76cc7.zip
py: Improve __bool__ and __len__ dispatch; add slots for them.
Diffstat (limited to 'py/runtime.c')
-rw-r--r--py/runtime.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/py/runtime.c b/py/runtime.c
index 6b3c8dc1d0..b1027de932 100644
--- a/py/runtime.c
+++ b/py/runtime.c
@@ -304,23 +304,23 @@ void rt_assign_inline_asm_code(uint unique_code_id, void *fun, uint len, int n_a
int rt_is_true(mp_obj_t arg) {
DEBUG_OP_printf("is true %p\n", arg);
- if (MP_OBJ_IS_SMALL_INT(arg)) {
+ if (arg == mp_const_false) {
+ return 0;
+ } else if (arg == mp_const_true) {
+ return 1;
+ } else if (arg == mp_const_none) {
+ return 0;
+ } else if (MP_OBJ_IS_SMALL_INT(arg)) {
if (MP_OBJ_SMALL_INT_VALUE(arg) == 0) {
return 0;
} else {
return 1;
}
- } else if (arg == mp_const_none) {
- return 0;
- } else if (arg == mp_const_false) {
- return 0;
- } else if (arg == mp_const_true) {
- return 1;
} else {
mp_obj_type_t *type = mp_obj_get_type(arg);
if (type->unary_op != NULL) {
mp_obj_t result = type->unary_op(RT_UNARY_OP_BOOL, arg);
- if (result != NULL) {
+ if (result != MP_OBJ_NULL) {
return result == mp_const_true;
}
}