Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
ca318bba
Commit
ca318bba
authored
Jan 13, 2014
by
Paul Sokolovsky
Browse files
mp_obj_equal(): Compare small and long ints properly.
By dispatching to long int methods.
parent
76a90f2f
Changes
1
Hide whitespace changes
Inline
Side-by-side
py/obj.c
View file @
ca318bba
...
...
@@ -108,9 +108,15 @@ bool mp_obj_equal(mp_obj_t o1, mp_obj_t o2) {
return
val
==
0
;
}
else
if
(
o2
==
mp_const_true
)
{
return
val
==
1
;
}
else
{
return
false
;
}
else
if
(
MP_OBJ_IS_TYPE
(
o2
,
&
int_type
))
{
// If o2 is long int, dispatch to its virtual methods
mp_obj_base_t
*
o
=
o2
;
if
(
o
->
type
->
binary_op
!=
NULL
)
{
mp_obj_t
r
=
o
->
type
->
binary_op
(
RT_COMPARE_OP_EQUAL
,
o2
,
o1
);
return
r
==
mp_const_true
?
true
:
false
;
}
}
return
false
;
}
}
else
if
(
MP_OBJ_IS_QSTR
(
o1
)
||
MP_OBJ_IS_QSTR
(
o2
))
{
return
false
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment