Skip to content

Commit

Permalink
small optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed May 11, 2014
1 parent 4a03caa commit 9221c12
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions lib/Mojo/UserAgent/Server.pm
Expand Up @@ -20,19 +20,11 @@ sub app {
return $self;
}

sub nb_url {
my $self = shift;
$self->_restart(0, @_) if !$self->{server} || @_;
return Mojo::URL->new("$self->{proto}://localhost:$self->{nb_port}/");
}
sub nb_url { shift->_url(1, @_) }

sub restart { shift->_restart(1) }

sub url {
my $self = shift;
$self->_restart(0, @_) if !$self->{server} || @_;
return Mojo::URL->new("$self->{proto}://localhost:$self->{port}/");
}
sub url { shift->_url(0, @_) }

sub _restart {
my ($self, $full, $proto) = @_;
Expand All @@ -56,6 +48,13 @@ sub _restart {
->start->ioloop->acceptor($server->acceptors->[0])->handle->sockport;
}

sub _url {
my ($self, $nb) = (shift, shift);
$self->_restart(0, @_) if !$self->{server} || @_;
my $port = $nb ? $self->{nb_port} : $self->{port};
return Mojo::URL->new("$self->{proto}://localhost:$port/");
}

1;

=encoding utf8
Expand Down

0 comments on commit 9221c12

Please sign in to comment.