From 11def613b6821bc305d1d54b5f4d21f3eb35d50b Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Fri, 12 Apr 2024 15:50:15 +0800 Subject: [PATCH] optimize `is_type` --- include/pocketpy/obj.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/include/pocketpy/obj.h b/include/pocketpy/obj.h index 28925ae1..86c041cc 100644 --- a/include/pocketpy/obj.h +++ b/include/pocketpy/obj.h @@ -149,8 +149,7 @@ inline bool is_type(PyObject* obj, Type type) { #if PK_DEBUG_EXTRA_CHECK if(obj == nullptr) throw std::runtime_error("is_type() called with nullptr"); #endif - if(type.index == kTpIntIndex) return is_int(obj); - return !is_tagged(obj) && obj->type == type; + return is_tagged(obj) ? type.index == kTpIntIndex : obj->type == type; } [[deprecated("use is_type() instead")]]