Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
small optimizations
  • Loading branch information
kraih committed Jul 11, 2012
1 parent 7572d14 commit 694a3c9
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 17 deletions.
3 changes: 1 addition & 2 deletions lib/Mojo/Exception.pm
Expand Up @@ -45,8 +45,7 @@ sub trace {
$start //= 1;
my @frames;
while (my @trace = caller($start++)) { push @frames, \@trace }
$self->frames(\@frames);
return $self;
return $self->frames(\@frames);
}

# "You killed zombie Flanders!
Expand Down
10 changes: 4 additions & 6 deletions lib/Mojo/Template.pm
Expand Up @@ -38,8 +38,7 @@ sub build {
my $self = shift;

# Lines
my (@lines, $cpst);
my $multi = 0;
my (@lines, $cpst, $multi);
for my $line (@{$self->tree}) {

# New line
Expand Down Expand Up @@ -79,8 +78,8 @@ sub build {
unless ($multi) {

# Escaped
my $a = $self->auto_escape;
if (($type eq 'escp' && !$a) || ($type eq 'expr' && $a)) {
my $escape = $self->auto_escape;
if (($type eq 'escp' && !$escape) || ($type eq 'expr' && $escape)) {
$lines[-1] .= "\$_M .= _escape";
$lines[-1] .= " scalar $value" if length $value;
}
Expand Down Expand Up @@ -199,8 +198,7 @@ sub parse {

# Split lines
my $state = 'text';
my @capture_token;
my $trimming = 0;
my ($trimming, @capture_token);
for my $line (split /\n/, $tmpl) {
$trimming = 0 if $state eq 'text';

Expand Down
2 changes: 1 addition & 1 deletion lib/Mojo/Transaction.pm
Expand Up @@ -271,7 +271,7 @@ message in C<error>, 400 and 500 responses also a code.
if (my $res = $tx->success) { say $res->body }
else {
my ($message, $code) = $tx->error;
say $code ? "$code $message response" : "Connection error: $message";
say $code ? "$code response: $message" : "Connection error: $message";
}
Error messages can be accessed with the C<error> method of the transaction
Expand Down
8 changes: 2 additions & 6 deletions lib/Mojo/UserAgent.pm
Expand Up @@ -72,13 +72,9 @@ sub build_websocket_tx { shift->transactor->websocket(@_) }

sub detect_proxy {
my $self = shift;

# Upper case gets priority
$self->http_proxy($ENV{HTTP_PROXY} || $ENV{http_proxy});
$self->https_proxy($ENV{HTTPS_PROXY} || $ENV{https_proxy});
$self->no_proxy([split /,/, $ENV{NO_PROXY} || $ENV{no_proxy} || '']);

return $self;
return $self->no_proxy([split /,/, $ENV{NO_PROXY} || $ENV{no_proxy} || '']);
}

sub need_proxy {
Expand Down Expand Up @@ -536,7 +532,7 @@ Mojo::UserAgent - Non-blocking I/O HTTP 1.1 and WebSocket user agent
if (my $res = $tx->success) { say $res->body }
else {
my ($message, $code) = $tx->error;
say $code ? "$code $message response" : "Connection error: $message";
say $code ? "$code response: $message" : "Connection error: $message";
}
# Quick JSON API request with Basic authentication
Expand Down
4 changes: 2 additions & 2 deletions lib/Mojo/Util.pm
Expand Up @@ -40,8 +40,8 @@ $REVERSE{$ENTITIES{$_}} //= $_ for sort grep {/;/} keys %ENTITIES;
our @EXPORT_OK = (
qw(b64_decode b64_encode camelize class_to_file class_to_path decamelize),
qw(decode encode get_line hmac_md5_sum hmac_sha1_sum html_escape),
qw(html_unescape md5_bytes md5_sum punycode_decode punycode_encode),
qw(quote secure_compare sha1_bytes sha1_sum slurp trim unquote url_escape),
qw(html_unescape md5_bytes md5_sum punycode_decode punycode_encode quote),
qw(secure_compare sha1_bytes sha1_sum slurp trim unquote url_escape),
qw(url_unescape xml_escape)
);

Expand Down

0 comments on commit 694a3c9

Please sign in to comment.