Skip to content

Commit

Permalink
do/while looks a little better
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Mar 3, 2016
1 parent 02d7ebf commit f00cf2c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions lib/Mojo/IOLoop.pm
Expand Up @@ -152,10 +152,10 @@ sub timer { shift->_timer(timer => @_) }

sub _id {
my $self = shift;
while (my $id = md5_sum 'c' . steady_time . rand) {
next if $self->{in}{$id} || $self->{out}{$id} || $self->{acceptors}{$id};
return $id;
}
my $id;
do { $id = md5_sum 'c' . steady_time . rand }
while $self->{in}{$id} || $self->{out}{$id} || $self->{acceptors}{$id};
return $id;
}

sub _in { scalar keys %{shift->{in} || {}} }
Expand Down
6 changes: 3 additions & 3 deletions lib/Mojo/Reactor/Poll.pm
Expand Up @@ -116,9 +116,9 @@ sub watch {

sub _id {
my $self = shift;
while (my $id = md5_sum 't' . steady_time . rand) {
return $id unless $self->{timers}{$id};
}
my $id;
do { $id = md5_sum 't' . steady_time . rand } while $self->{timers}{$id};
return $id;
}

sub _next {
Expand Down

0 comments on commit f00cf2c

Please sign in to comment.