Re: [PATCH] interpret_nth_last_branch(): avoid traversing the reflogs twice
- From
Thomas Rast <trast@student.ethz.ch>
- Date
- Jan 20, 2009, 00:41 UTC
- Message-ID
- <200901200141.14129.trast@student.ethz.ch>
- In-Reply-To
- <alpine.DEB.1.00.0901200121190.3586@pacific.mpi-cbg.de>
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