summaryrefslogtreecommitdiff
path: root/signal.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-07-30 13:46:41 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-07-30 13:46:41 (GMT)
commite5a7c2db988db967140da2e11bdf8bb8e85d7769 (patch)
tree166b511cff19346eb98877fb00dcd759d4a82e75 /signal.c
parent3b895e8355b06facb4e80b27e527d560af4fd65a (diff)
get rid of function calls in RSTRING_PTR
* process.c (rlimit_resource_type, rlimit_resource_value): get rid of function calls in RSTRING_PTR(), as it evaluates the argument twice. * re.c (match_backref_number): ditto. * signal.c (esignal_init, rb_f_kill, trap_signm): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47006 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'signal.c')
-rw-r--r--signal.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/signal.c b/signal.c
index bf1b5d3..3017061 100644
--- a/signal.c
+++ b/signal.c
@@ -301,7 +301,8 @@ esignal_init(int argc, VALUE *argv, VALUE self)
}
else {
int len = sizeof(signame_prefix);
- signm = SYMBOL_P(sig) ? RSTRING_PTR(rb_sym2str(sig)) : StringValuePtr(sig);
+ if (SYMBOL_P(sig)) sig = rb_sym2str(sig); else StringValue(sig);
+ signm = RSTRING_PTR(sig);
if (strncmp(signm, signame_prefix, len) == 0) {
signm += len;
len = 0;
@@ -408,7 +409,8 @@ rb_f_kill(int argc, const VALUE *argv)
break;
case T_SYMBOL:
- s = RSTRING_PTR(rb_sym2str(argv[0]));
+ str = rb_sym2str(argv[0]);
+ s = RSTRING_PTR(str);
if (!s) rb_raise(rb_eArgError, "bad signal");
goto str_signal;
@@ -1044,7 +1046,8 @@ trap_signm(VALUE vsig)
break;
case T_SYMBOL:
- s = RSTRING_PTR(rb_sym2str(vsig));
+ vsig = rb_sym2str(vsig);
+ s = RSTRING_PTR(vsig);
if (!s) rb_raise(rb_eArgError, "bad signal");
goto str_signal;