Skip to content

Commit

Permalink
no need for an extra function
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Mar 8, 2016
1 parent 55e1427 commit 4e5419c
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions lib/Mojo/Server/Morbo.pm
Expand Up @@ -19,10 +19,18 @@ sub check {
}

sub modified_files {
my $self = shift;
my $self = shift;

my $cache = $self->{cache} ||= {};
my @files = grep { _check($cache, $_) }
map { -f $_ && -r _ ? $_ : files $_ } @{$self->watch};
my @files;
for my $file (map { -f $_ && -r _ ? $_ : files $_ } @{$self->watch}) {
my ($size, $mtime) = (stat $file)[7, 9];
my $stats = $cache->{$file} ||= [$^T, $size];
next if $mtime <= $stats->[0] && $size == $stats->[1];
@$stats = ($mtime, $size);
push @files, $file;
}

return \@files;
}

Expand All @@ -44,16 +52,6 @@ sub run {
exit 0;
}

sub _check {
my ($cache, $file) = @_;

# Check if modify time and/or size have changed
my ($size, $mtime) = (stat $file)[7, 9];
my $stats = $cache->{$file} ||= [$^T, $size];
return undef if $mtime <= $stats->[0] && $size == $stats->[1];
return !!($cache->{$file} = [$mtime, $size]);
}

sub _manage {
my $self = shift;

Expand Down

0 comments on commit 4e5419c

Please sign in to comment.