diff options
author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-04-08 03:05:15 +0000 |
---|---|---|
committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-04-08 03:05:15 +0000 |
commit | ae13ab24669e787a73a98a533d4bd7db8c4b49ab (patch) | |
tree | 97b8c5eb99f5237a02a60a0d044471ca64ec9803 /object.c | |
parent | 6cb682a48005f43f3f1599d6c510523de237040d (diff) | |
download | ruby-ae13ab24669e787a73a98a533d4bd7db8c4b49ab.tar.gz |
* object.c (rb_obj_ivar_set): call to_str for string only once.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40178 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'object.c')
-rw-r--r-- | object.c | 12 |
1 files changed, 8 insertions, 4 deletions
@@ -2189,12 +2189,16 @@ rb_obj_ivar_set(VALUE obj, VALUE iv, VALUE val) QUOTE_ID(id)); } } - else if (!rb_is_instance_name(iv)) { + else { + VALUE name = rb_check_string_type(iv); + if (NIL_P(name)) { + rb_raise(rb_eTypeError, "%+"PRIsVALUE" is not a symbol or string", iv); + } + if (!rb_is_instance_name(name)) { rb_name_error_str(iv, "`%"PRIsVALUE"' is not allowed as an instance variable name", QUOTE(iv)); - } - else { - id = rb_to_id(iv); + } + id = rb_to_id(name); } return rb_ivar_set(obj, id, val); } |