فهرست منبع

optimize `is_type`

blueloveTH 2 سال پیش
والد
کامیت
11def613b6
1فایلهای تغییر یافته به همراه1 افزوده شده و 2 حذف شده
  1. 1 2
      include/pocketpy/obj.h

+ 1 - 2
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")]]