about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2011-02-01 14:00:07 -0800
committerEric Wong <normalperson@yhbt.net>2011-02-01 14:01:12 -0800
commit879f2f0ee9133f34ec3e24141bdb4936e3408d3a (patch)
tree328f02019776ea139f38abb3a60ce2ee975d1845
parent499f158c74b7c455dca08fc30be88cb699ee24c6 (diff)
downloadkgio-879f2f0ee9133f34ec3e24141bdb4936e3408d3a.tar.gz
Needless calls to rb_intern are wasteful in even semi-frequently
used code.
-rw-r--r--ext/kgio/read_write.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/ext/kgio/read_write.c b/ext/kgio/read_write.c
index 571eed8..9f7bce8 100644
--- a/ext/kgio/read_write.c
+++ b/ext/kgio/read_write.c
@@ -1,6 +1,7 @@
 #include "kgio.h"
 static VALUE sym_wait_readable, sym_wait_writable;
 static VALUE eErrno_EPIPE, eErrno_ECONNRESET;
+static ID id_set_backtrace;
 
 /*
  * we know MSG_DONTWAIT works properly on all stream sockets under Linux
@@ -21,7 +22,7 @@ static void raise_empty_bt(VALUE err, const char *msg)
         VALUE exc = rb_exc_new2(err, msg);
         VALUE bt = rb_ary_new();
 
-        rb_funcall(exc, rb_intern("set_backtrace"), 1, bt);
+        rb_funcall(exc, id_set_backtrace, 1, bt);
         rb_exc_raise(exc);
 }
 
@@ -444,7 +445,7 @@ void init_kgio_read_write(void)
          * Kgio::LOCALHOST constant for UNIX domain sockets.
          */
         rb_define_attr(mSocketMethods, "kgio_addr", 1, 1);
-
+        id_set_backtrace = rb_intern("set_backtrace");
         eErrno_EPIPE = rb_const_get(rb_mErrno, rb_intern("EPIPE"));
         eErrno_ECONNRESET = rb_const_get(rb_mErrno, rb_intern("ECONNRESET"));
         rb_include_module(mPipeMethods, mWaiters);