> On Nov 29, 2016, at 03:30, Samuel Williams <space.ship.traveller / gmail.com> wrote:
> 
> I'm implementing some code that calls the same method multiple times
> from C. I'd like to cache the method to avoid costly method lookup. Is
> this possible?
> 
> Something like
> 
>    METHOD * m = rb_method_lookup(object, rb_intern("doit"));
>    rb_invoke(m, args...)

You can use rb_obj_method (just like you would use #method in pure ruby).

I'd measure first that this is your actual bottleneck before you go an optimize a tenth of a percent away.


Unsubscribe: <mailto:ruby-talk-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>