From 6d61241b5ce1e3baefcbd3379241f55c2af8fa1b Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 19 May 2011 21:58:55 +0000 Subject: use rb_call_super instead of calling for_fd It's fewer lines of code and cleaner in cases where "new" and "for_fd" are the same underlying method. --- ext/sleepy_penguin/eventfd.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'ext/sleepy_penguin/eventfd.c') diff --git a/ext/sleepy_penguin/eventfd.c b/ext/sleepy_penguin/eventfd.c index d291bff..4da5e45 100644 --- a/ext/sleepy_penguin/eventfd.c +++ b/ext/sleepy_penguin/eventfd.c @@ -1,7 +1,6 @@ #ifdef HAVE_SYS_EVENTFD_H #include "sleepy_penguin.h" #include -static ID id_for_fd; /* * call-seq: @@ -21,7 +20,7 @@ static ID id_for_fd; */ static VALUE s_new(int argc, VALUE *argv, VALUE klass) { - VALUE _initval, _flags; + VALUE _initval, _flags, rv; unsigned initval; int flags; int fd; @@ -40,7 +39,8 @@ static VALUE s_new(int argc, VALUE *argv, VALUE klass) rb_sys_fail("eventfd"); } - return rb_funcall(klass, id_for_fd, 1, INT2NUM(fd)); + rv = INT2FIX(fd); + return rb_call_super(1, &rv); } struct efd_args { @@ -170,6 +170,5 @@ void sleepy_penguin_init_eventfd(void) #endif rb_define_method(cEventFD, "value", getvalue, -1); rb_define_method(cEventFD, "incr", incr, -1); - id_for_fd = rb_intern("for_fd"); } #endif /* HAVE_SYS_EVENTFD_H */ -- cgit v1.2.3-24-ge0c7