optimize is_type

This commit is contained in:
blueloveTH 2024-04-12 15:50:15 +08:00
parent 2129392b0e
commit 11def613b6

View File

@ -149,8 +149,7 @@ inline bool is_type(PyObject* obj, Type type) {
#if PK_DEBUG_EXTRA_CHECK #if PK_DEBUG_EXTRA_CHECK
if(obj == nullptr) throw std::runtime_error("is_type() called with nullptr"); if(obj == nullptr) throw std::runtime_error("is_type() called with nullptr");
#endif #endif
if(type.index == kTpIntIndex) return is_int(obj); return is_tagged(obj) ? type.index == kTpIntIndex : obj->type == type;
return !is_tagged(obj) && obj->type == type;
} }
[[deprecated("use is_type() instead")]] [[deprecated("use is_type() instead")]]