Skip to content

Commit

Permalink
small optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Apr 3, 2012
1 parent 1371e13 commit 701245a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 20 deletions.
4 changes: 2 additions & 2 deletions lib/Mojo/UserAgent/Transactor.pm
Expand Up @@ -66,7 +66,7 @@ sub form {
# Multipart
$headers->content_type('multipart/form-data') if $multipart;
if (($headers->content_type || '') eq 'multipart/form-data') {
my $parts = $self->_multipart($params->to_hash, $encoding);
my $parts = $self->_multipart($encoding, $params->to_hash);
$req->content(
Mojo::Content::MultiPart->new(headers => $headers, parts => $parts));
}
Expand Down Expand Up @@ -198,7 +198,7 @@ sub websocket {
}

sub _multipart {
my ($self, $form, $encoding) = @_;
my ($self, $encoding, $form) = @_;

# Parts
my @parts;
Expand Down
20 changes: 4 additions & 16 deletions lib/Mojo/Util.pm
Expand Up @@ -284,6 +284,9 @@ my %REVERSE_ENTITIES = reverse %ENTITIES;
# "apos"
$ENTITIES{apos} = 39;

# Entities regex for html_unescape
my $ENTITIES_RE = qr/&(?:\#((?:\d{1,7}|x[0-9A-Fa-f]{1,6}))|([A-Za-z]{1,8}));/;

# Encode cache
my %ENCODE;

Expand Down Expand Up @@ -403,22 +406,7 @@ sub html_escape {
# Just relax and it'll come, son."
sub html_unescape {
my $string = shift;
$string =~ s/
&
(?:
\#
(
(?:
\d{1,7} # Number
|
x[0-9A-Fa-f]{1,6} # Hex
)
)
|
([A-Za-z]{1,8}) # Name
)
;
/_unescape($1, $2)/gex;
$string =~ s/$ENTITIES_RE/_unescape($1, $2)/ge;
return $string;
}

Expand Down
4 changes: 2 additions & 2 deletions lib/Mojolicious/Routes/Pattern.pm
Expand Up @@ -111,15 +111,15 @@ sub shape_match {
sub _compile {
my $self = shift;

# Compile format regular expression
# Compile format regex
my $reqs = $self->reqs;
if (!exists $reqs->{format} || $reqs->{format}) {
my $format =
defined $reqs->{format} ? _compile_req($reqs->{format}) : '([^/]+)';
$self->format(qr#\.$format$#);
}

# Compile tree to regular expression
# Compile tree to regex
my $block = '';
my $regex = '';
my $optional = 1;
Expand Down

0 comments on commit 701245a

Please sign in to comment.