Return gas mix from model

Robert Helling helling at
Tue Oct 17 13:32:22 PDT 2017


> On 17. Oct 2017, at 22:27, Linus Torvalds <torvalds at> 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.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 529 bytes
Desc: Message signed with OpenPGP
URL: <>

More information about the subsurface mailing list