aboutsummaryrefslogtreecommitdiffstats
path: root/pack.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-11-12 06:12:13 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-11-12 06:12:13 +0000
commit6c42b0b9e7f3b1d6cfa925fba8ce2d832aeac0f1 (patch)
tree09eb6272b35289f9bbd77d6a9f20bc929392aca1 /pack.c
parent257c8ff19bbf501a010d03d02dc95f7a92233c43 (diff)
downloadruby-6c42b0b9e7f3b1d6cfa925fba8ce2d832aeac0f1.tar.gz
pack.c: simplify
* pack.c (str_associate): remove unnecessary branch. the argument must be a plain vanilla string object. * pack.c (str_associated): use rb_ivar_lookup to give the undefined value. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56740 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'pack.c')
-rw-r--r--pack.c16
1 files changed, 3 insertions, 13 deletions
diff --git a/pack.c b/pack.c
index 40f409df13..4e1198b635 100644
--- a/pack.c
+++ b/pack.c
@@ -116,24 +116,14 @@ static ID id_associated;
static void
str_associate(VALUE str, VALUE add)
{
- VALUE assoc;
-
- assoc = rb_attr_get(str, id_associated);
- if (RB_TYPE_P(assoc, T_ARRAY)) {
- /* already associated */
- rb_ary_concat(assoc, add);
- }
- else {
- rb_ivar_set(str, id_associated, add);
- }
+ /* assert(NIL_P(rb_attr_get(str, id_associated))); */
+ rb_ivar_set(str, id_associated, add);
}
static VALUE
str_associated(VALUE str)
{
- VALUE assoc = rb_attr_get(str, id_associated);
- if (NIL_P(assoc)) assoc = Qfalse;
- return assoc;
+ return rb_ivar_lookup(str, id_associated, Qfalse);
}
void