threads / patch / 25689

patchgitweb: Time::HiRes is in core for Perl 5.8

Subject: [PATCH] gitweb: Time::HiRes is in core for Perl 5.8

## tl;dr

3 messages between Nov 9, 2010 and Nov 11, 2010. Diffs are folded; open one to read it.

replies: 2people: 2as markdown or json

Jakub Narebski· Nov 9, 2010, 18:27 UTC · lore

Therefore there is no need to check if it is installed. We can also import gettimeofday and tv_interval.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
 gitweb/gitweb.perl |   12 +++++-------
 1 files changed, 5 insertions(+), 7 deletions(-)
Show changes to gitweb/gitweb.perl +5 −7
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 5445159..0813479 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -17,12 +17,10 @@ use Encode;
 use Fcntl ':mode';
 use File::Find qw();
 use File::Basename qw(basename);
+use Time::HiRes qw(gettimeofday tv_interval);
 binmode STDOUT, ':utf8';
 
-our $t0;
-if (eval { require Time::HiRes; 1; }) {
-	$t0 = [Time::HiRes::gettimeofday()];
-}
+our $t0 = [ gettimeofday() ];
 our $number_of_git_cmds = 0;
 
 BEGIN {
@@ -1065,7 +1063,7 @@ sub dispatch {
 }
 
 sub reset_timer {
-	our $t0 = [Time::HiRes::gettimeofday()]
+	our $t0 = [ gettimeofday() ]
 		if defined $t0;
 	our $number_of_git_cmds = 0;
 }
@@ -3601,7 +3599,7 @@ sub git_footer_html {
 		print "<div id=\"generating_info\">\n";
 		print 'This page took '.
 		      '<span id="generating_time" class="time_span">'.
-		      Time::HiRes::tv_interval($t0, [Time::HiRes::gettimeofday()]).
+		      tv_interval($t0, [ gettimeofday() ]).
 		      ' seconds </span>'.
 		      ' and '.
 		      '<span id="generating_cmd">'.
@@ -5310,7 +5308,7 @@ sub git_blame_common {
 		print 'END';
 		if (defined $t0 && gitweb_check_feature('timed')) {
 			print ' '.
-			      Time::HiRes::tv_interval($t0, [Time::HiRes::gettimeofday()]).
+			      tv_interval($t0, [ gettimeofday() ]).
 			      ' '.$number_of_git_cmds;
 		}
 		print "\n";
Junio C Hamano· Nov 11, 2010, 17:12 UTC · re: Jakub Narebski · lore

Re: [PATCH] gitweb: Time::HiRes is in core for Perl 5.8

Jakub Narebski <jnareb@gmail.com> writes:
> Therefore there is no need to check if it is installed.  We can also
> import gettimeofday and tv_interval.
>
> Signed-off-by: Jakub Narebski <jnareb@gmail.com>

I think "... and 'use 5.008' is at the begining of the script already, " is missing before that "Therefore". But otherwise it is a reasonable thing to do.

Thanks.
Jakub Narebski· Nov 11, 2010, 19:01 UTC · re: Junio C Hamano · lore

Re: [PATCH] gitweb: Time::HiRes is in core for Perl 5.8

Junio C Hamano wrote:
Show 8 quoted lines
> Jakub Narebski <jnareb@gmail.com> writes:
> 
> > Therefore there is no need to check if it is installed.  We can also
> > import gettimeofday and tv_interval.
> >
> > Signed-off-by: Jakub Narebski <jnareb@gmail.com>
> 
> I think "... and 'use 5.008' is at the begining of the script already, "
because gitweb requires Perl 5.8, in order to have good Unicode support.
> is missing before that "Therefore".  But otherwise it is a reasonable
> thing to do.
> 
> Thanks.
Would you amend commit message when applying it, then?
-- 
Jakub Narebski
Poland

← back to recent threads