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
This commit is contained in:
parent
4e41467894
commit
0913d67f5d
16
pack.c
16
pack.c
@ -116,24 +116,14 @@ static ID id_associated;
|
|||||||
static void
|
static void
|
||||||
str_associate(VALUE str, VALUE add)
|
str_associate(VALUE str, VALUE add)
|
||||||
{
|
{
|
||||||
VALUE assoc;
|
/* assert(NIL_P(rb_attr_get(str, id_associated))); */
|
||||||
|
rb_ivar_set(str, id_associated, add);
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
str_associated(VALUE str)
|
str_associated(VALUE str)
|
||||||
{
|
{
|
||||||
VALUE assoc = rb_attr_get(str, id_associated);
|
return rb_ivar_lookup(str, id_associated, Qfalse);
|
||||||
if (NIL_P(assoc)) assoc = Qfalse;
|
|
||||||
return assoc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Loading…
x
Reference in New Issue
Block a user