From e86e7feafd4829341b8cf22576dd781575b88401 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Fri, 22 Sep 2023 00:32:48 +0800 Subject: [PATCH] ... --- include/pocketpy/vm.h | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/include/pocketpy/vm.h b/include/pocketpy/vm.h index edca3e1f..2df7425a 100644 --- a/include/pocketpy/vm.h +++ b/include/pocketpy/vm.h @@ -505,11 +505,8 @@ PY_CAST_INT(unsigned long) PY_CAST_INT(unsigned long long) template<> inline float py_cast(VM* vm, PyObject* obj){ + if(is_float(obj)) return BitsCvt(PK_BITS(obj) & Number::c1)._float; i64 bits; - if(is_float(obj)){ - bits = PK_BITS(obj) & Number::c1; - return BitsCvt(bits)._float; - } if(try_cast_int(obj, &bits)) return (float)bits; vm->TypeError("expected 'int' or 'float', got " + OBJ_NAME(vm->_t(obj)).escape()); return 0; @@ -518,11 +515,8 @@ template<> inline float _py_cast(VM* vm, PyObject* obj){ return py_cast(vm, obj); } template<> inline double py_cast(VM* vm, PyObject* obj){ + if(is_float(obj)) return BitsCvt(PK_BITS(obj) & Number::c1)._float; i64 bits; - if(is_float(obj)){ - bits = PK_BITS(obj) & Number::c1; - return BitsCvt(bits)._float; - } if(try_cast_int(obj, &bits)) return (float)bits; vm->TypeError("expected 'int' or 'float', got " + OBJ_NAME(vm->_t(obj)).escape()); return 0;