git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Narebski <jnareb@gmail.com>
To: Junio C Hamano <junkio@cox.net>
Cc: git@vger.kernel.org, Robert Fitzsimons <robfitz@273k.net>
Subject: Re: [PATCH] Small optimizations to gitweb
Date: Tue, 19 Dec 2006 01:59:23 +0100	[thread overview]
Message-ID: <200612190159.24173.jnareb@gmail.com> (raw)
In-Reply-To: <7vbqm0vkd6.fsf@assigned-by-dhcp.cox.net>

Junio C Hamano wrote:
> Jakub Narebski <jnareb@gmail.com> writes:
> 
>> Actually, that is needed to implement checking if we have more than
>> the number of commits to show to add '...' at the end only if there
>> are some commits which we don't show.
> 
> The counting code in git_*_body is seriously unusual to tempt
> anybody who reviews the code to reduce that 17 to 16.
> 
> The caller says:
> 
> 	git_shortlog_body(\@revlist, 0, 15, $refs,
> 	                  $cgi->a({-href => href(action=>"shortlog")}, "..."));
> 
> If it counts up, especially if it counts from zero, the loop
> would usually say:
> 
> 	for (i = bottom; i < end; i++)
> 
> and anybody who reads that caller would expect it to show 15
> lines of output.
> 
> But the actual code does this instead:
> 
>     sub git_shortlog_body {
>             # uses global variable $project
>             my ($revlist, $from, $to, $refs, $extra) = @_;
> 
>             $from = 0 unless defined $from;
>             $to = $#{$revlist} if (!defined $to || $#{$revlist} < $to);
>             ...
>             for (my $i = $from; $i <= $to; $i++) {
>                     ... draw each item ...
>             }

Well, this should be then corrected perhaps to

            my ($revlist, $begin, $end, $refs, $extra) = @_;

            $begin = 0 unless defined $from;
            $end = scalar(@$revlist) if (!defined $end || @$revlist <= $end);
            ...
            for (my $i = $begin; $i < $end; $i++) {
                    ... draw each item ...
            }

I thought that $from..$to ($from <= i <= $to) is more natural
and easier to understand than $begin..$end ($begin <= i < $end)...
guess I guessed wrong.

>             if (defined $extra) {
>                     print "<tr>\n" .
>                           "<td colspan=\"4\">$extra</td>\n" .
>                           "</tr>\n";
>             }
>     }
> 
> By the way, I wonder how that $extra is omitted when $revlist is
> longer than $to; it should be a trivial fix but it seems to me
> that it is always spitted out with the current code.

We should check if we want to omit $extra, either in caller or
in callee, the *_body subroutine itself.

-- 
Jakub Narebski

  reply	other threads:[~2006-12-19  0:56 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-12-22 19:38 [PATCH 1/4] gitweb: Add missing show '...' links change Robert Fitzsimons
2006-12-18 22:43 ` [PATCH] Small optimizations to gitweb Robert Fitzsimons
2006-12-18 23:17   ` Jakub Narebski
2006-12-18 23:45     ` Junio C Hamano
2006-12-19  0:59       ` Jakub Narebski [this message]
2006-12-19  5:48         ` Junio C Hamano
2006-12-19 11:14         ` [PATCH] gitweb: Show '...' links in "summary" view only if there are more items Jakub Narebski
2006-12-19 12:08           ` Robert Fitzsimons
2006-12-19 12:28             ` Jakub Narebski
2006-12-19 12:41               ` Robert Fitzsimons
2006-12-19 12:42               ` Jakub Narebski
2006-12-19 18:05               ` Junio C Hamano
     [not found]   ` <8edd09bf9114df40281e7527df8704b1a94bb280.1166813858.git.robfitz@273k.net>
2006-12-22 19:38     ` [PATCH 1/4] gitweb: Add missing show '...' links change Robert Fitzsimons
2006-12-22 19:38       ` [PATCH 2/4] gitweb: optimize git_get_last_activity Robert Fitzsimons
2006-12-22 19:38         ` [PATCH 3/4] gitweb: optimize git_shortlog_body Robert Fitzsimons
2006-12-22 19:38           ` [PATCH 4/4] gitweb: optimize git_summary Robert Fitzsimons
2006-12-22 20:07         ` [PATCH 2/4] gitweb: optimize git_get_last_activity Jakub Narebski
2006-12-22 20:09 ` [PATCH 1/4] gitweb: Add missing show '...' links change Jakub Narebski
2006-12-22 21:52   ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200612190159.24173.jnareb@gmail.com \
    --to=jnareb@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=junkio@cox.net \
    --cc=robfitz@273k.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).