mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
thread.c: no function callsin RARRAY_LEN
* ext/thread/thread.c (queue_length, queue_num_waiting): avoid function calls in RARRAY_LEN macro which evaluates the argument multiple times. * ext/thread/thread.c (rb_szqueue_num_waiting): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48315 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
72ce1a4759
commit
13d241489a
1 changed files with 6 additions and 3 deletions
|
@ -243,13 +243,15 @@ rb_queue_push(VALUE self, VALUE obj)
|
|||
static unsigned long
|
||||
queue_length(VALUE self)
|
||||
{
|
||||
return RARRAY_LEN(GET_QUEUE_QUE(self));
|
||||
VALUE que = GET_QUEUE_QUE(self);
|
||||
return RARRAY_LEN(que);
|
||||
}
|
||||
|
||||
static unsigned long
|
||||
queue_num_waiting(VALUE self)
|
||||
{
|
||||
return RARRAY_LEN(GET_QUEUE_WAITERS(self));
|
||||
VALUE waiters = GET_QUEUE_WAITERS(self);
|
||||
return RARRAY_LEN(waiters);
|
||||
}
|
||||
|
||||
struct waiting_delete {
|
||||
|
@ -548,7 +550,8 @@ static VALUE
|
|||
rb_szqueue_num_waiting(VALUE self)
|
||||
{
|
||||
long len = queue_num_waiting(self);
|
||||
len += RARRAY_LEN(GET_SZQUEUE_WAITERS(self));
|
||||
VALUE waiters = GET_SZQUEUE_WAITERS(self);
|
||||
len += RARRAY_LEN(waiters);
|
||||
return ULONG2NUM(len);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue