summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-04-04 08:23:10 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-04-04 08:23:10 +0000
commitfd7dc1b6eaf13be7e8270558d12e17864a7446b1 (patch)
treed47456f2cd32c729e45bfdb101f0613acfbc54f9 /string.c
parent5e2c39ed226d084a340c6f860344062bd32d56b9 (diff)
reduce overhead of TYPE
* array.c (ary_join_1): reduce overhead of TYPE(). * eval.c (rb_frozen_class_p, rb_mod_{append,prepend}_features): ditto. * string.c (rb_to_id): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40105 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r--string.c20
1 files changed, 7 insertions, 13 deletions
diff --git a/string.c b/string.c
index 8bbd8a4c41..8b85739e70 100644
--- a/string.c
+++ b/string.c
@@ -8152,24 +8152,18 @@ rb_to_id(VALUE name)
{
VALUE tmp;
- switch (TYPE(name)) {
- default:
+ if (SYMBOL_P(name)) {
+ return SYM2ID(name);
+ }
+ if (!RB_TYPE_P(name, T_STRING)) {
tmp = rb_check_string_type(name);
if (NIL_P(tmp)) {
- tmp = rb_inspect(name);
- rb_raise(rb_eTypeError, "%s is not a symbol",
- RSTRING_PTR(tmp));
+ rb_raise(rb_eTypeError, "%+"PRIsVALUE" is not a symbol",
+ name);
}
name = tmp;
- /* fall through */
- case T_STRING:
- name = rb_str_intern(name);
- /* fall through */
- case T_SYMBOL:
- return SYM2ID(name);
}
-
- UNREACHABLE;
+ return rb_intern_str(name);
}
/*