summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
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);
}
/*