@@ -26,10 +26,7 @@ typedef struct msgpack_packer_ext_registry_t msgpack_packer_ext_registry_t;
2626
2727struct msgpack_packer_ext_registry_t {
2828 VALUE hash ;
29- /*
30- * lookup cache for subclasses of registered classes
31- */
32- VALUE cache ;
29+ VALUE cache ; // lookup cache for ext types inherited from a super class
3330};
3431
3532void msgpack_packer_ext_registry_static_init ();
@@ -49,7 +46,7 @@ void msgpack_packer_ext_registry_dup(msgpack_packer_ext_registry_t* src,
4946VALUE msgpack_packer_ext_registry_put (msgpack_packer_ext_registry_t * pkrg ,
5047 VALUE ext_class , int ext_type , VALUE proc , VALUE arg );
5148
52- static int msgpack_packer_ext_find_inherited (VALUE key , VALUE value , VALUE arg )
49+ static int msgpack_packer_ext_find_superclass (VALUE key , VALUE value , VALUE arg )
5350{
5451 VALUE * args = (VALUE * ) arg ;
5552 if (key == Qundef ) {
@@ -66,16 +63,16 @@ static int msgpack_packer_ext_find_inherited(VALUE key, VALUE value, VALUE arg)
6663static inline VALUE msgpack_packer_ext_registry_lookup (msgpack_packer_ext_registry_t * pkrg ,
6764 VALUE ext_class , int * ext_type_result )
6865{
69- VALUE e = rb_hash_lookup (pkrg -> hash , ext_class );
70- if (e != Qnil ) {
71- * ext_type_result = FIX2INT (rb_ary_entry (e , 0 ));
72- return rb_ary_entry (e , 1 );
66+ VALUE type = rb_hash_lookup (pkrg -> hash , ext_class );
67+ if (type != Qnil ) {
68+ * ext_type_result = FIX2INT (rb_ary_entry (type , 0 ));
69+ return rb_ary_entry (type , 1 );
7370 }
7471
75- VALUE c = rb_hash_lookup (pkrg -> cache , ext_class );
76- if (c != Qnil ) {
77- * ext_type_result = FIX2INT (rb_ary_entry (c , 0 ));
78- return rb_ary_entry (c , 1 );
72+ VALUE type_inht = rb_hash_lookup (pkrg -> cache , ext_class );
73+ if (type_inht != Qnil ) {
74+ * ext_type_result = FIX2INT (rb_ary_entry (type_inht , 0 ));
75+ return rb_ary_entry (type_inht , 1 );
7976 }
8077
8178 /*
@@ -84,12 +81,12 @@ static inline VALUE msgpack_packer_ext_registry_lookup(msgpack_packer_ext_regist
8481 VALUE args [2 ];
8582 args [0 ] = ext_class ;
8683 args [1 ] = Qnil ;
87- rb_hash_foreach (pkrg -> hash , msgpack_packer_ext_find_inherited , (VALUE ) args );
84+ rb_hash_foreach (pkrg -> hash , msgpack_packer_ext_find_superclass , (VALUE ) args );
8885
89- VALUE hit = args [1 ];
90- if (hit != Qnil ) {
91- rb_hash_aset (pkrg -> cache , ext_class , hit );
92- return hit ;
86+ VALUE superclass = args [1 ];
87+ if (superclass != Qnil ) {
88+ rb_hash_aset (pkrg -> cache , ext_class , superclass );
89+ return superclass ;
9390 }
9491
9592 return Qnil ;
0 commit comments