Skip to content

Instantly share code, notes, and snippets.

/slower.diff Secret

Created September 1, 2015 18:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/f28834b1050c46b9b792 to your computer and use it in GitHub Desktop.
Save anonymous/f28834b1050c46b9b792 to your computer and use it in GitHub Desktop.
diff --git a/lib/Mojo/Util.pm b/lib/Mojo/Util.pm
index 8983d3a..5cf74bd 100644
--- a/lib/Mojo/Util.pm
+++ b/lib/Mojo/Util.pm
@@ -235,8 +235,8 @@ sub slurp {
my $path = shift;
open my $file, '<', $path or croak qq{Can't open file "$path": $!};
- my $ret = my $content = '';
- while ($ret = $file->sysread(my $buffer, 131072, 0)) { $content .= $buffer }
+ my ($ret, $content, $size) = ('', '', -s $file || 131072);
+ while ($ret = $file->sysread(my $buffer, $size, 0)) { $content .= $buffer }
croak qq{Can't read from file "$path": $!} unless defined $ret;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment