Return gas mix from model

Dirk Hohndel dirk at hohndel.org
Tue Oct 17 16:19:18 PDT 2017


> On Oct 17, 2017, at 4:32 PM, Robert Helling <helling at atdotde.de> wrote:
> 
> Linus,
> 
>> On 17. Oct 2017, at 22:27, Linus Torvalds <torvalds at linux-foundation.org <mailto:torvalds at linux-foundation.org>> 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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.subsurface-divelog.org/pipermail/subsurface/attachments/20171017/f5dbc532/attachment.html>


More information about the subsurface mailing list