> On Oct 17, 2017, at 4:32 PM, Robert Helling <[email protected]> wrote:
> 
> Linus,
> 
>> On 17. Oct 2017, at 22:27, Linus Torvalds <[email protected] 
>> <mailto:[email protected]>> wrote:
>> 
>>> 
>>> the problem I see is that we need that information in the diveProfileItem
>>> which gets its data from the divePlotDataModel. And that has random access
>>> not sequential (at least in theory).
>> 
>> You can do random access without the loop by just doing
>> 
>>>           struct gasmix *gasmix = NULL;
>>>           struct event *ev = NULL;
>>>           gasmix = get_gasmix(dive, dc, time, &ev, gasmix);
>> 
>> the loop is just the efficient model when you do it over and over again.
>> 
>> Please don't add pointless redundancy.
> 
> But that means we loop over all (actually half on average) events every time 
> we need that value (i.e. once per plot_item). Don’t you think the 
> computational cost of that is worth computing this once (with the loop you 
> mentioned) where we have to do it anyway and then simply do a lookup? I.e. 
> you really want to save two ints per plotitem at the expense of looping over 
> events (note that we need that info also for example when computing MOD etc, 
> so the loop is not only once per plot.

Correct me if I'm wrong, but isn't the list of events for most reasonable dives 
(cough) something like <10 items? And even for impressive cave dives with very 
chatty dive computers like the EON Steel maybe a few dozen?

I'm not arguing against your solution, but I think Linus has a valid point. 
This is a reasonably quick lookup.

/D

_______________________________________________
subsurface mailing list
[email protected]
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface

Reply via email to