From 34bab04861ce6ec5c94a45e605294f4c66e8367c Mon Sep 17 00:00:00 2001 From: Jeong YunWon Date: Wed, 25 Dec 2019 20:12:59 +0900 Subject: [PATCH] Refactor objint --- vm/src/obj/objint.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/vm/src/obj/objint.rs b/vm/src/obj/objint.rs index fafcc6980..4db985aeb 100644 --- a/vm/src/obj/objint.rs +++ b/vm/src/obj/objint.rs @@ -223,8 +223,8 @@ impl PyInt { where F: Fn(&BigInt, &BigInt) -> bool, { - if objtype::isinstance(&other, &vm.ctx.int_type()) { - vm.ctx.new_bool(op(&self.value, get_value(&other))) + if let Some(other) = other.payload_if_subclass::(vm) { + vm.ctx.new_bool(op(&self.value, &other.value)) } else { vm.ctx.not_implemented() } @@ -265,8 +265,8 @@ impl PyInt { where F: Fn(&BigInt, &BigInt) -> BigInt, { - if objtype::isinstance(&other, &vm.ctx.int_type()) { - vm.ctx.new_int(op(&self.value, get_value(&other))) + if let Some(other) = other.payload_if_subclass::(vm) { + vm.ctx.new_int(op(&self.value, &other.value)) } else { vm.ctx.not_implemented() } @@ -277,8 +277,8 @@ impl PyInt { where F: Fn(&BigInt, &BigInt) -> PyResult, { - if objtype::isinstance(&other, &vm.ctx.int_type()) { - op(&self.value, get_value(&other)) + if let Some(other) = other.payload_if_subclass::(vm) { + op(&self.value, &other.value) } else { Ok(vm.ctx.not_implemented()) }