Skip to content

Commit

Permalink
Define PREV_CLASS_SERIAL
Browse files Browse the repository at this point in the history
Avoids genereating a "throwaway" sentinel class serial. There wasn't any
read harm in doing so (we're at no risk of exhaustion and there'd be no
measurable performance impact), but if feels cleaner that all class
serials actually end up assigned and used (especially now that we won't
overwrite them in a single method definition).
  • Loading branch information
jhawthorn authored and tenderlove committed Dec 17, 2019
1 parent d7a50a5 commit 8e56d3a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions vm_insnhelper.h
Expand Up @@ -184,6 +184,7 @@ CC_SET_ME(CALL_CACHE cc, const rb_callable_method_entry_t *me)
} while (0)
#endif

#define PREV_CLASS_SERIAL() (ruby_vm_class_serial)
#define NEXT_CLASS_SERIAL() (++ruby_vm_class_serial)
#define GET_GLOBAL_METHOD_STATE() (ruby_vm_global_method_state)
#define INC_GLOBAL_METHOD_STATE() (++ruby_vm_global_method_state)
Expand Down
2 changes: 1 addition & 1 deletion vm_method.c
Expand Up @@ -104,7 +104,7 @@ rb_clear_method_cache_by_class(VALUE klass)
INC_GLOBAL_METHOD_STATE();
}
else {
rb_serial_t old_serial = rb_next_class_serial();
rb_serial_t old_serial = PREV_CLASS_SERIAL();
rb_class_clear_method_cache(klass, (VALUE)&old_serial);
}
}
Expand Down

0 comments on commit 8e56d3a

Please sign in to comment.