@@ -3553,16 +3553,15 @@ rb_reg_equal(VALUE re1, VALUE re2)
35533553static VALUE
35543554match_hash (VALUE match )
35553555{
3556- const struct re_registers * regs ;
35573556 st_index_t hashval ;
35583557
35593558 match_check (match );
35603559 hashval = rb_hash_start (rb_str_hash (RMATCH (match )-> str ));
35613560 hashval = rb_hash_uint (hashval , reg_hash (match_regexp (match )));
3562- regs = RMATCH_REGS (match );
3563- hashval = rb_hash_uint (hashval , regs -> num_regs );
3564- hashval = rb_hash_uint (hashval , rb_memhash (regs -> beg , regs -> num_regs * sizeof (* regs -> beg )));
3565- hashval = rb_hash_uint (hashval , rb_memhash (regs -> end , regs -> num_regs * sizeof (* regs -> end )));
3561+ int num_regs = RMATCH_NREGS (match );
3562+ hashval = rb_hash_uint (hashval , num_regs );
3563+ hashval = rb_hash_uint (hashval , rb_memhash (RMATCH_BEG_PTR ( match ), num_regs * sizeof (OnigPosition )));
3564+ hashval = rb_hash_uint (hashval , rb_memhash (RMATCH_END_PTR ( match ), num_regs * sizeof (OnigPosition )));
35663565 hashval = rb_hash_end (hashval );
35673566 return ST2FIX (hashval );
35683567}
@@ -3579,18 +3578,15 @@ match_hash(VALUE match)
35793578static VALUE
35803579match_equal (VALUE match1 , VALUE match2 )
35813580{
3582- const struct re_registers * regs1 , * regs2 ;
3583-
35843581 if (match1 == match2 ) return Qtrue ;
35853582 if (!RB_TYPE_P (match2 , T_MATCH )) return Qfalse ;
35863583 if (!RMATCH (match1 )-> regexp || !RMATCH (match2 )-> regexp ) return Qfalse ;
35873584 if (!rb_str_equal (RMATCH (match1 )-> str , RMATCH (match2 )-> str )) return Qfalse ;
35883585 if (!rb_reg_equal (match_regexp (match1 ), match_regexp (match2 ))) return Qfalse ;
3589- regs1 = RMATCH_REGS (match1 );
3590- regs2 = RMATCH_REGS (match2 );
3591- if (regs1 -> num_regs != regs2 -> num_regs ) return Qfalse ;
3592- if (memcmp (regs1 -> beg , regs2 -> beg , regs1 -> num_regs * sizeof (* regs1 -> beg ))) return Qfalse ;
3593- if (memcmp (regs1 -> end , regs2 -> end , regs1 -> num_regs * sizeof (* regs1 -> end ))) return Qfalse ;
3586+ int num_regs = RMATCH_NREGS (match1 );
3587+ if (num_regs != RMATCH_NREGS (match2 )) return Qfalse ;
3588+ if (memcmp (RMATCH_BEG_PTR (match1 ), RMATCH_BEG_PTR (match2 ), num_regs * sizeof (OnigPosition ))) return Qfalse ;
3589+ if (memcmp (RMATCH_END_PTR (match1 ), RMATCH_END_PTR (match2 ), num_regs * sizeof (OnigPosition ))) return Qfalse ;
35943590 return Qtrue ;
35953591}
35963592
0 commit comments