diff options
author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-04-07 12:28:21 +0000 |
---|---|---|
committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-04-07 12:28:21 +0000 |
commit | 6cb682a48005f43f3f1599d6c510523de237040d (patch) | |
tree | ed684a439ea987d7ce6c4cb86bae00ecb2de30dd /object.c | |
parent | d9ff5c2230fbdb0aa76462df1e23c4d9cc646150 (diff) |
* object.c (rb_mod_const_set): call to_str for string only once.
to_str was called from rb_is_const_name and rb_to_id before.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40175 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'object.c')
-rw-r--r-- | object.c | 15 |
1 files changed, 10 insertions, 5 deletions
@@ -2051,12 +2051,17 @@ rb_mod_const_set(VALUE mod, VALUE name, VALUE value) QUOTE_ID(id)); } } - else if (!rb_is_const_name(name)) { - rb_name_error_str(name, "wrong constant name %"PRIsVALUE, - QUOTE(name)); - } else { - id = rb_to_id(name); + VALUE cname = rb_check_string_type(name); + if (NIL_P(cname)) { + rb_raise(rb_eTypeError, "%+"PRIsVALUE" is not a symbol or string", + name); + } + if (!rb_is_const_name(cname)) { + rb_name_error_str(cname, "wrong constant name %"PRIsVALUE, + QUOTE(cname)); + } + id = rb_to_id(cname); } rb_const_set(mod, id, value); return value; |