mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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
This commit is contained in:
parent
3b895e8355
commit
e5a7c2db98
3 changed files with 12 additions and 7 deletions
|
@ -4529,7 +4529,8 @@ rlimit_resource_type(VALUE rtype)
|
|||
|
||||
switch (TYPE(rtype)) {
|
||||
case T_SYMBOL:
|
||||
name = RSTRING_PTR(rb_sym2str(rtype));
|
||||
v = rb_sym2str(rtype);
|
||||
name = RSTRING_PTR(v);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -4564,7 +4565,8 @@ rlimit_resource_value(VALUE rval)
|
|||
|
||||
switch (TYPE(rval)) {
|
||||
case T_SYMBOL:
|
||||
name = RSTRING_PTR(rb_sym2str(rval));
|
||||
v = rb_sym2str(rval);
|
||||
name = RSTRING_PTR(v);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
4
re.c
4
re.c
|
@ -1082,8 +1082,8 @@ match_backref_number(VALUE match, VALUE backref)
|
|||
return NUM2INT(backref);
|
||||
|
||||
case T_SYMBOL:
|
||||
name = RSTRING_PTR(rb_sym2str(backref));
|
||||
break;
|
||||
backref = rb_sym2str(backref);
|
||||
/* fall through */
|
||||
|
||||
case T_STRING:
|
||||
name = StringValueCStr(backref);
|
||||
|
|
9
signal.c
9
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;
|
||||
|
||||
|
|
Loading…
Reference in a new issue