File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -73,13 +73,23 @@ rb_mcache_resize(struct rb_meth_cache *cache)
7373 tmp .method_state = cache -> method_state ;
7474 tmp .class_serial = cache -> class_serial ;
7575 tmp .capa = cache -> capa * 2 ;
76+ redo :
7677 tmp .entries = xcalloc (tmp .capa , sizeof (struct cache_entry ));
7778 for (i = 0 ; i < cache -> capa ; i ++ ) {
78- if (cache -> entries [i ].mid ) {
79+ if (cache -> entries [i ].mid && ( cache -> entries [ i ]. me & ~ 1 ) ) {
7980 struct cache_entry * ent = & cache -> entries [i ];
8081 rb_mcache_insert (& tmp , ent -> mid , ent -> me & ~1 , ent -> defined_class );
8182 }
8283 }
84+ /* deal with lots of cached method_missing */
85+ if (tmp .size < tmp .capa / 8 ) {
86+ xfree (tmp .entries );
87+ while (tmp .capa > tmp .size * 2 && tmp .capa > 8 ) {
88+ tmp .capa /= 2 ;
89+ }
90+ tmp .size = 0 ;
91+ goto redo ;
92+ }
8393 xfree (cache -> entries );
8494 * cache = tmp ;
8595}
You can’t perform that action at this time.
0 commit comments