Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
another small optimization
  • Loading branch information
kraih committed Apr 6, 2012
1 parent aeb813b commit c84d885
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions lib/Mojo/Asset/File.pm
Expand Up @@ -24,8 +24,7 @@ has handle => sub {
# Open new or temporary file
my $base = File::Spec->catfile($self->tmpdir, 'mojo.tmp');
my $name = $path // $base;
my $fh;
until (sysopen $fh, $name, O_CREAT | O_EXCL | O_RDWR) {
until ($handle->open($name, O_CREAT | O_EXCL | O_RDWR)) {
croak qq/Can't open file "$name": $!/
if defined $path || $! != $!{EEXIST};
$name = "$base." . md5_sum(time . $$ . rand 9999999);
Expand All @@ -35,9 +34,6 @@ has handle => sub {
# Enable automatic cleanup
$self->cleanup(1) unless defined $self->cleanup;

# Open for read/write access
$handle->fdopen(fileno($fh), "+>") or croak qq/Can't open file "$name": $!/;

return $handle;
};
has tmpdir => sub { $ENV{MOJO_TMPDIR} || File::Spec->tmpdir };
Expand Down

0 comments on commit c84d885

Please sign in to comment.