1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Convert initial contents before allocating queue buffer

This commit is contained in:
Nobuyoshi Nakada 2021-06-15 15:55:52 +09:00
parent f0818982e9
commit b32e6c168a
No known key found for this signature in database
GPG key ID: 7CD2805BFA3770C6

View file

@ -859,11 +859,13 @@ rb_queue_initialize(int argc, VALUE *argv, VALUE self)
{
VALUE initial;
struct rb_queue *q = queue_ptr(self);
if ((argc = rb_scan_args(argc, argv, "01", &initial)) == 1) {
initial = rb_to_array(initial);
}
RB_OBJ_WRITE(self, &q->que, ary_buf_new());
list_head_init(queue_waitq(q));
rb_scan_args(argc, argv, "01", &initial);
if (argc == 1) {
rb_ary_concat(q->que, rb_to_array(initial));
rb_ary_concat(q->que, initial);
}
return self;
}