mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Cleanup: pass gasmix by value
In a previous commit, the get_gasmix_* functions were changed to return by value. For consistency, also pass gasmix by value. Note that on common 64-bit platforms struct gasmix is the size of a pointer [2 * 32 bit vs. 64 bit] and therefore uses the same space on the stack. On 32-bit platforms, the stack use is probably doubled, but in return a dereference is avoided. Supporting arbitrary gas-mixes (H2, Ar, ...) will be such an invasive change that going back to pointers is probably the least of our worries. This commit is a step in const-ifying input parameters (passing by value is the ultimate way of signaling that the input parameter will not be changed [unless there are references to said parameter]). Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
5c4569247a
commit
360f07e453
28 changed files with 214 additions and 215 deletions
|
@ -51,7 +51,7 @@ struct event *DiveEventItem::getEvent()
|
|||
return internalEvent;
|
||||
}
|
||||
|
||||
void DiveEventItem::setEvent(struct event *ev, struct gasmix *lastgasmix)
|
||||
void DiveEventItem::setEvent(struct event *ev, struct gasmix lastgasmix)
|
||||
{
|
||||
if (!ev)
|
||||
return;
|
||||
|
@ -63,7 +63,7 @@ void DiveEventItem::setEvent(struct event *ev, struct gasmix *lastgasmix)
|
|||
recalculatePos(true);
|
||||
}
|
||||
|
||||
void DiveEventItem::setupPixmap(struct gasmix *lastgasmix)
|
||||
void DiveEventItem::setupPixmap(struct gasmix lastgasmix)
|
||||
{
|
||||
const IconMetrics& metrics = defaultIconMetrics();
|
||||
#ifndef SUBSURFACE_MOBILE
|
||||
|
@ -94,13 +94,13 @@ void DiveEventItem::setupPixmap(struct gasmix *lastgasmix)
|
|||
} else if (event_is_gaschange(internalEvent)) {
|
||||
struct gasmix mix = get_gasmix_from_event(&displayed_dive, internalEvent);
|
||||
struct icd_data icd_data;
|
||||
bool icd = isobaric_counterdiffusion(lastgasmix, &mix, &icd_data);
|
||||
bool icd = isobaric_counterdiffusion(lastgasmix, mix, &icd_data);
|
||||
if (mix.he.permille) {
|
||||
if (icd)
|
||||
setPixmap(EVENT_PIXMAP_BIGGER(":gaschange-trimix-ICD-icon"));
|
||||
else
|
||||
setPixmap(EVENT_PIXMAP_BIGGER(":gaschange-trimix-icon"));
|
||||
} else if (gasmix_is_air(&mix)) {
|
||||
} else if (gasmix_is_air(mix)) {
|
||||
if (icd)
|
||||
setPixmap(EVENT_PIXMAP_BIGGER(":gaschange-air-ICD-icon"));
|
||||
else
|
||||
|
@ -165,7 +165,7 @@ void DiveEventItem::setupPixmap(struct gasmix *lastgasmix)
|
|||
#undef EVENT_PIXMAP_BIGGER
|
||||
}
|
||||
|
||||
void DiveEventItem::setupToolTipString(struct gasmix *lastgasmix)
|
||||
void DiveEventItem::setupToolTipString(struct gasmix lastgasmix)
|
||||
{
|
||||
// we display the event on screen - so translate
|
||||
QString name = gettextFromC::tr(internalEvent->name);
|
||||
|
@ -177,12 +177,12 @@ void DiveEventItem::setupToolTipString(struct gasmix *lastgasmix)
|
|||
struct gasmix mix = get_gasmix_from_event(&displayed_dive, internalEvent);
|
||||
struct membuffer mb = {};
|
||||
name += ": ";
|
||||
name += gasname(&mix);
|
||||
name += gasname(mix);
|
||||
|
||||
/* Do we have an explicit cylinder index? Show it. */
|
||||
if (internalEvent->gas.index >= 0)
|
||||
name += tr(" (cyl. %1)").arg(internalEvent->gas.index + 1);
|
||||
bool icd = isobaric_counterdiffusion(lastgasmix, &mix, &icd_data);
|
||||
bool icd = isobaric_counterdiffusion(lastgasmix, mix, &icd_data);
|
||||
if (icd_data.dHe < 0) {
|
||||
put_format(&mb, "\n%s %s:%+.3g%% %s:%+.3g%%%s%+.3g%%",
|
||||
qPrintable(tr("ICD")),
|
||||
|
@ -192,7 +192,7 @@ void DiveEventItem::setupToolTipString(struct gasmix *lastgasmix)
|
|||
name += QString::fromUtf8(mb.buffer, mb.len);
|
||||
free_buffer(&mb);
|
||||
}
|
||||
*lastgasmix = mix;
|
||||
lastgasmix = mix;
|
||||
} else if (same_string(internalEvent->name, "modechange")) {
|
||||
name += QString(": %1").arg(gettextFromC::tr(divemode_text_ui[internalEvent->value]));
|
||||
} else if (value) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue