Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
not using a second file descriptor is a lot faster
  • Loading branch information
kraih committed Feb 5, 2017
1 parent 61e53e4 commit fe96caf
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/Mojo/Asset/File.pm
Expand Up @@ -111,7 +111,13 @@ sub mtime { (stat shift->handle)[9] }

sub size { -s shift->handle }

sub slurp { Mojo::File->new(shift->path)->slurp }
sub slurp {
my $handle = shift->handle;
$handle->sysseek(0, SEEK_SET);
my $ret = my $content = '';
while ($ret = $handle->sysread(my $buffer, 131072, 0)) { $content .= $buffer }
return defined $ret ? $content : croak qq{Can't read from asset: $!};
}

1;

Expand Down

0 comments on commit fe96caf

Please sign in to comment.