Skip to content

Commit

Permalink
improved get_line performance
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Feb 8, 2014
1 parent 117ac45 commit 54d13a7
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 17 deletions.
1 change: 1 addition & 0 deletions Changes
@@ -1,5 +1,6 @@

4.78 2014-02-08
- Improved get_line performance.
- Fixed ";" handling in Mojo::Parameters to be compliant with the HTML
Living Standard.

Expand Down
8 changes: 2 additions & 6 deletions lib/Mojo/Headers.pm
Expand Up @@ -31,8 +31,6 @@ sub add {
# Make sure we have a normal case entry for name
my $key = lc $name;
$self->{normalcase}{$key} //= $name unless $NORMALCASE{$key};

# Add lines
push @{$self->{headers}{$key}}, map { ref $_ eq 'ARRAY' ? $_ : [$_] } @_;

return $self;
Expand Down Expand Up @@ -131,10 +129,8 @@ sub remove {

sub to_hash {
my ($self, $multi) = @_;
my %hash;
$hash{$_} = $multi ? [$self->header($_)] : scalar $self->header($_)
for @{$self->names};
return \%hash;
return {map { $_ => $multi ? [$self->header($_)] : scalar $self->header($_) }
@{$self->names}};
}

sub to_string {
Expand Down
12 changes: 1 addition & 11 deletions lib/Mojo/Util.pm
Expand Up @@ -111,17 +111,7 @@ sub dumper { Data::Dumper->new([@_])->Indent(1)->Sortkeys(1)->Terse(1)->Dump }
sub encode { _encoding($_[0])->encode("$_[1]") }
sub get_line {
# Locate line ending
return undef if (my $pos = index ${$_[0]}, "\x0a") == -1;
# Extract line and ending
my $line = substr ${$_[0]}, 0, $pos + 1, '';
$line =~ s/\x0d?\x0a$//;
return $line;
}
sub get_line { ${$_[0]} =~ s/^(.*?)\x0d?\x0a// ? $1 : undef }
sub hmac_sha1_sum { hmac_sha1_hex(@_) }
Expand Down

0 comments on commit 54d13a7

Please sign in to comment.