hmm, maybe someone can get a pull request for implementing this optimization :)
While I know you meant that comment in jest, it suggests that I wasn't clear enough.
My implicit argument is that there's there's no reason to believe that line counting adds anything more than trivial overhead to the less output, so there's no reason to even consider this optimization, much less getting to the point to make a pull request.
This is with "less 458", "Copyright (C) 1984-2012". I downloaded and compiled stock 487 and the best-of-3 times went up to 0:02.94 for both cases.
Checking the source code, it does not appear to use knowledge of the previous output index in order to save time. The relevant code is:
where