ruby-changes:40264
From: nobu <ko1@a...>
Date: Thu, 29 Oct 2015 16:21:47 +0900 (JST)
Subject: [ruby-changes:40264] nobu:r52345 (trunk): gc.c: fix UNLIKELY usage
nobu 2015-10-29 16:21:24 +0900 (Thu, 29 Oct 2015) New Revision: 52345 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=52345 Log: gc.c: fix UNLIKELY usage * gc.c (gc_event_hook_needed_p): UNLIKELY makes no sense for boolean flag value. * gc.c (gc_event_hook, newobj_init): use in conditions instead. Modified files: trunk/gc.c Index: gc.c =================================================================== --- gc.c (revision 52344) +++ gc.c (revision 52345) @@ -1696,10 +1696,10 @@ gc_event_hook_body(rb_thread_t *th, rb_o https://github.com/ruby/ruby/blob/trunk/gc.c#L1696 } #define gc_event_hook_available_p(objspace) ((objspace)->flags.has_hook) -#define gc_event_hook_needed_p(objspace, event) (UNLIKELY((objspace)->hook_events & (event))) +#define gc_event_hook_needed_p(objspace, event) ((objspace)->hook_events & (event)) #define gc_event_hook(objspace, event, data) do { \ - if (gc_event_hook_needed_p(objspace, event)) { \ + if (UNLIKELY(gc_event_hook_needed_p(objspace, event))) { \ gc_event_hook_body(GET_THREAD(), (objspace), (event), (data)); \ } \ } while (0) @@ -1760,7 +1760,7 @@ newobj_init(VALUE klass, VALUE flags, VA https://github.com/ruby/ruby/blob/trunk/gc.c#L1760 objspace->total_allocated_objects++; - if (hook_needed) { + if (UNLIKELY(hook_needed)) { gc_event_hook(objspace, RUBY_INTERNAL_EVENT_NEWOBJ, obj); } gc_report(5, objspace, "newobj: %s\n", obj_info(obj)); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/