Subject: Re: [PATCH] interpret_nth_last_branch(): avoid traversing the reflogs twice

From: Thomas Rast <[email-masked]>
Date: Tue, 20 Jan 2009 01:41:08 +0100

Johannes Schindelin wrote:
> 1) it introduces a lot of code, with a lot of possibility for bugs to hide 

And I can understand in the case of read_ref_at() since there the
translation is really nontrivial (though I'd readily put the blame on
the optimized-to-death original code ;-).  But in the case of
for_each_reflog_ent(), it should be really straightforward.

> 2) on Windows, mmap() is really implemented as xmalloc() && fread().  So 
>    all the shortcomings of what Junio said about my array approach would 
>    hold true for your approach, too.

But the @{} syntax _already_ uses mmap via read_ref_at().  And both
uses of for_each_reflog_ent() I'm aware of, the existing git log -g
and the present @{-N} syntax, have to read to the end anyway because
they're mostly interested in the newer stuff.

So while the mmap() might occasionally grab a few more MB of RAM than
would actually be required with simple line-based input, Windows
has to read the whole reflog no matter what.

(Well, unless we make a for_each_reflog_ent_backward() that can jump
in somewhere near the end and start parsing lines backwards.)

-- 
Thomas Rast
trast@{inf,student}.ethz.ch