From f295a96773aa512cbd71131cfae7691455ccf777 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Mon, 23 Dec 2013 20:09:40 +0100 Subject: optimize hide_past (check first, invoke DateTime later) --- lib/Travel/Status/DE/URA.pm | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'lib/Travel/Status/DE/URA.pm') diff --git a/lib/Travel/Status/DE/URA.pm b/lib/Travel/Status/DE/URA.pm index c525ffd..4683f34 100644 --- a/lib/Travel/Status/DE/URA.pm +++ b/lib/Travel/Status/DE/URA.pm @@ -148,16 +148,18 @@ sub results { next; } + $timestamp /= 1000; + + if ( $hide_past and $ts_now > $timestamp ) { + next; + } + my $dt_dep = DateTime->from_epoch( - epoch => $timestamp / 1000, + epoch => $timestamp, time_zone => 'Europe/Berlin' ); my $ts_dep = $dt_dep->epoch; - if ( $hide_past and $dt_dep->subtract_datetime($dt_now)->is_negative ) { - next; - } - if ($full_routes) { @route = map { [ $_->[9] / 1000, $_->[1] ] } grep { $_->[8] == $tripid } @{ $self->{raw_list} }; -- cgit v1.2.3