mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
Share freeze option handling
This commit is contained in:
parent
e724857f42
commit
47a9b58b2a
3 changed files with 11 additions and 24 deletions
14
object.c
14
object.c
|
@ -369,7 +369,6 @@ init_copy(VALUE dest, VALUE obj)
|
|||
}
|
||||
}
|
||||
|
||||
static VALUE freeze_opt(int argc, VALUE *argv);
|
||||
static VALUE immutable_obj_clone(VALUE obj, VALUE kwfreeze);
|
||||
static VALUE mutable_obj_clone(VALUE obj, VALUE kwfreeze);
|
||||
PUREFUNC(static inline int special_object_p(VALUE obj)); /*!< \private */
|
||||
|
@ -418,12 +417,12 @@ rb_obj_clone2(rb_execution_context_t *ec, VALUE obj, VALUE freeze)
|
|||
VALUE
|
||||
rb_immutable_obj_clone(int argc, VALUE *argv, VALUE obj)
|
||||
{
|
||||
VALUE kwfreeze = freeze_opt(argc, argv);
|
||||
VALUE kwfreeze = rb_get_freeze_opt(argc, argv);
|
||||
return immutable_obj_clone(obj, kwfreeze);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
freeze_opt(int argc, VALUE *argv)
|
||||
VALUE
|
||||
rb_get_freeze_opt(int argc, VALUE *argv)
|
||||
{
|
||||
static ID keyword_ids[1];
|
||||
VALUE opt;
|
||||
|
@ -657,9 +656,10 @@ static VALUE
|
|||
rb_obj_init_clone(int argc, VALUE *argv, VALUE obj)
|
||||
{
|
||||
VALUE orig, opts;
|
||||
rb_scan_args(argc, argv, "1:", &orig, &opts);
|
||||
/* Ignore a freeze keyword */
|
||||
if (argc == 2) (void)freeze_opt(1, &opts);
|
||||
if (rb_scan_args(argc, argv, "1:", &orig, &opts) < argc) {
|
||||
/* Ignore a freeze keyword */
|
||||
rb_get_freeze_opt(1, &opts);
|
||||
}
|
||||
rb_funcall(obj, id_init_copy, 1, orig);
|
||||
return obj;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue