Index: gtype.c
===================================================================
RCS file: /cvs/gnome/glib/gobject/gtype.c,v
retrieving revision 1.59
diff -u -p -u -r1.59 gtype.c
--- gtype.c	7 Feb 2003 22:04:24 -0000	1.59
+++ gtype.c	22 Feb 2003 12:13:07 -0000
@@ -141,7 +141,6 @@ static IFaceHolder*			type_iface_peek_ho
 static gboolean				type_node_is_a_L		(TypeNode		*node,
 									 TypeNode		*iface_node);
 
-
 /* --- structures --- */
 struct _TypeNode
 {
@@ -160,6 +159,8 @@ struct _TypeNode
     IFaceEntry  *iface_entries;		/* for !iface types */
     GType       *prerequisistes;
   } _prot;
+  GType        is_a_cache_1;
+  GType        is_a_cache_2;
   GType        supers[1]; /* flexible array */
 };
 #define SIZEOF_BASE_TYPE_NODE()			(G_STRUCT_OFFSET (TypeNode, supers))
@@ -355,6 +356,9 @@ type_node_any_new_W (TypeNode           
   node->data = NULL;
   node->qname = g_quark_from_string (name);
   node->global_gdata = NULL;
+
+  node->is_a_cache_1 = 0;
+  node->is_a_cache_2 = 0;
   
   g_hash_table_insert (static_type_nodes_ht,
 		       GUINT_TO_POINTER (node->qname),
@@ -2645,14 +2649,30 @@ g_type_check_instance_is_a (GTypeInstanc
 {
   TypeNode *node, *iface;
   gboolean check;
-  
+  gint hit;
+
   if (!type_instance || !type_instance->g_class)
     return FALSE;
-  
+
   node = lookup_type_node_I (type_instance->g_class->g_type);
+  if (!node)
+    return FALSE;
+
+  hit  = (node->is_a_cache_1 == iface_type);
+  hit |= ((node->is_a_cache_2 == iface_type) << 1);
+
+  if (G_LIKELY (hit))
+    return TRUE;
+
   iface = lookup_type_node_I (iface_type);
-  check = node && node->is_instantiatable && iface && type_node_conforms_to_U (node, iface, TRUE, FALSE);
+  check = node->is_instantiatable && iface && type_node_conforms_to_U (node, iface, TRUE, FALSE);
   
+  if (check)
+    {
+      node->is_a_cache_1 = node->is_a_cache_2;
+      node->is_a_cache_2 = iface_type;
+    }
+
   return check;
 }
 
