[glib/final-type-speedup] gtype: Speed up type checks for final types




commit 0ddea2d8e2786d056f718f03033e408be4754c0e
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon May 30 00:08:46 2022 -0400

    gtype: Speed up type checks for final types
    
    If a type is final, it is enough to compare the
    instance type for equality, since it can't have
    a derived type.

 gobject/gtype.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
---
diff --git a/gobject/gtype.h b/gobject/gtype.h
index 66cac1fc58..24b507bb46 100644
--- a/gobject/gtype.h
+++ b/gobject/gtype.h
@@ -1464,7 +1464,7 @@ guint     g_type_get_type_registration_serial (void);
   G_GNUC_UNUSED static inline ModuleObjName * MODULE##_##OBJ_NAME (gpointer ptr) {                       \
     return G_TYPE_CHECK_INSTANCE_CAST (ptr, module_obj_name##_get_type (), ModuleObjName); }             \
   G_GNUC_UNUSED static inline gboolean MODULE##_IS_##OBJ_NAME (gpointer ptr) {                           \
-    return G_TYPE_CHECK_INSTANCE_TYPE (ptr, module_obj_name##_get_type ()); }                            \
+    return ptr != NULL && G_OBJECT_TYPE (ptr) == module_obj_name##_get_type (); }                            
\
   G_GNUC_END_IGNORE_DEPRECATIONS
 
 /**


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]