git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] gitweb.cgi: git_blame2: slight optimization reading the blame lines

From
LTLuben Tuikov <ltuikov@yahoo.com>
Date
Jul 23, 2006, 21:17 UTC
Message-ID
<20060723211748.77065.qmail@web31814.mail.mud.yahoo.com>

Eliminate git_read_blame_line() -- move that code inline and optimize it.

Signed-off-by: Luben Tuikov <ltuikov@yahoo.com>
---
 gitweb/gitweb.cgi |   19 +++++--------------
 1 files changed, 5 insertions(+), 14 deletions(-)
diff --git a/gitweb/gitweb.cgi b/gitweb/gitweb.cgi
index 16340f2..7fbfc0d 100755
--- a/gitweb/gitweb.cgi
+++ b/gitweb/gitweb.cgi
@@ -1252,15 +1252,6 @@ sub git_tag {
 	git_footer_html();
 }
 
-sub git_read_blame_line {
-	my %bl;
-	$_ = shift;
-
-	($bl{'hash'}, $bl{'lineno'}, $bl{'data'}) = /^([0-9a-fA-F]{40}).*?(\d+)\)\s{1}(\s*.*)/;
-
-	return %bl;
-}
-
 sub git_blame2 {
 	my $fd;
 	my $ftype;
@@ -1302,13 +1293,12 @@ sub git_blame2 {
 	print "<div class=\"page_body\">\n";
 	print "<table class=\"blame\">\n";
 	print "<tr><th>Commit</th><th>Line</th><th>Data</th></tr>\n";
-	while (my $line = <$fd>) {
-		my %blame_line = git_read_blame_line($line);
-		my $full_rev = $blame_line{'hash'};
+	while (<$fd>) {
+		/^([0-9a-fA-F]{40}).*?(\d+)\)\s{1}(\s*.*)/;
+		my $full_rev = $1;
 		my $rev = substr($full_rev, 0, 8);
-		my $lineno = $blame_line{'lineno'};
-		my $data = $blame_line{'data'};
+		my $lineno = $2;
+		my $data = $3;
 
 		if (!defined $last_rev) {
 			$last_rev = $full_rev;
-- 
1.4.2.rc1.g9b54
Message 1 of 1 in “gitweb.cgi: git_blame2: slight optimization reading the blame lines”
  1. gitweb.cgi: git_blame2: slight optimization reading the blame linesLuben Tuikov, Jul 23, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.