diff options
| author | Daniel Friesel <derf@finalrewind.org> | 2011-05-18 08:22:28 +0200 | 
|---|---|---|
| committer | Daniel Friesel <derf@finalrewind.org> | 2011-05-18 08:24:16 +0200 | 
| commit | f37a988533a55020ad7a397b0be4b5bad6151a4a (patch) | |
| tree | 1186ac607764b64895ff834c3424d74056cb0bfc | |
| parent | a146fdcd6fb2ad84625c29876c1fd1a780fbf0b3 (diff) | |
Do not use autodie. Not counting disk IO, this increases performance by ~25%
| -rwxr-xr-x | bin/hashl | 8 | ||||
| -rw-r--r-- | lib/App/Hashl.pm | 13 | 
2 files changed, 12 insertions, 9 deletions
| @@ -5,11 +5,9 @@  use strict;  use warnings;  use 5.010; -use autodie;  use App::Hashl;  use Cwd; -use Digest::SHA qw(sha1_hex);  use File::Copy;  use File::Find;  use Getopt::Long; @@ -90,7 +88,8 @@ sub copy_file {  		mkdirs($incoming_dir, $base);  	} -	copy($file, "${to}/${base}"); +	copy($file, "${to}/${base}") +		or die("Cannot copy ${file} to ${to}/${base}: $!\n");  }  sub db_find_new { @@ -192,7 +191,8 @@ sub mkdirs {  	for my $dir (split(qr{/}, $new)) {  		$base .= "/$dir";  		if (! -d $base) { -			mkdir($base); +			mkdir($base) +				or die("Cannot create ${base}: $!\n");  		}  	}  } diff --git a/lib/App/Hashl.pm b/lib/App/Hashl.pm index 0e08794..c0b7e8c 100644 --- a/lib/App/Hashl.pm +++ b/lib/App/Hashl.pm @@ -2,7 +2,6 @@ package App::Hashl;  use strict;  use warnings; -use autodie;  use 5.010;  use Digest::SHA qw(sha1_hex); @@ -106,10 +105,14 @@ sub hash_file {  	my ($self, $file) = @_;  	my ($fh, $data); -	open($fh, '<', $file); -	binmode($fh); -	read($fh, $data, $self->{config}->{read_size}); -	close($fh); +	open($fh, '<', $file) +		or die("Can't open ${file} for reading: $!\n");; +	binmode($fh) +		or die("Can't set binmode on ${file}: $!\n"); +	read($fh, $data, $self->{config}->{read_size}) +		or die("Can't read ${file}: $!\n"); +	close($fh) +		or die("Can't close ${file}: $!\n");  	return sha1_hex($data);  } | 
