mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Cleanup: turn GET_PRESSURE macro into inline function
There is absolutely no reason to use a macro here. The only argument that can be made is consistency with the other pressure-macros, but those too are questionable. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
1eafd500e3
commit
29005b578d
3 changed files with 22 additions and 17 deletions
|
@ -178,8 +178,8 @@ static int get_local_sac(struct plot_data *entry1, struct plot_data *entry2, str
|
||||||
|
|
||||||
if (duration <= 0)
|
if (duration <= 0)
|
||||||
return 0;
|
return 0;
|
||||||
a.mbar = GET_PRESSURE(entry1, 0);
|
a.mbar = get_plot_pressure(entry1, 0);
|
||||||
b.mbar = GET_PRESSURE(entry2, 0);
|
b.mbar = get_plot_pressure(entry2, 0);
|
||||||
if (!b.mbar || a.mbar <= b.mbar)
|
if (!b.mbar || a.mbar <= b.mbar)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -663,8 +663,8 @@ static int sac_between(struct dive *dive, struct plot_data *first, struct plot_d
|
||||||
if (!(gases & (1u << i)))
|
if (!(gases & (1u << i)))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
a.mbar = GET_PRESSURE(first, i);
|
a.mbar = get_plot_pressure(first, i);
|
||||||
b.mbar = GET_PRESSURE(last, i);
|
b.mbar = get_plot_pressure(last, i);
|
||||||
cyl = dive->cylinder + i;
|
cyl = dive->cylinder + i;
|
||||||
cyluse = gas_volume(cyl, a) - gas_volume(cyl, b);
|
cyluse = gas_volume(cyl, a) - gas_volume(cyl, b);
|
||||||
if (cyluse > 0)
|
if (cyluse > 0)
|
||||||
|
@ -698,7 +698,7 @@ static unsigned int have_pressures(struct plot_data *entry, unsigned int gases)
|
||||||
for (i = 0; i < MAX_CYLINDERS; i++) {
|
for (i = 0; i < MAX_CYLINDERS; i++) {
|
||||||
unsigned int mask = 1 << i;
|
unsigned int mask = 1 << i;
|
||||||
if (gases & mask) {
|
if (gases & mask) {
|
||||||
if (!GET_PRESSURE(entry, i))
|
if (!get_plot_pressure(entry, i))
|
||||||
gases &= ~mask;
|
gases &= ~mask;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1394,7 +1394,7 @@ static void plot_string(struct plot_info *pi, struct plot_data *entry, struct me
|
||||||
depthvalue = get_depth_units(entry->depth, NULL, &depth_unit);
|
depthvalue = get_depth_units(entry->depth, NULL, &depth_unit);
|
||||||
put_format_loc(b, translate("gettextFromC", "@: %d:%02d\nD: %.1f%s\n"), FRACTION(entry->sec, 60), depthvalue, depth_unit);
|
put_format_loc(b, translate("gettextFromC", "@: %d:%02d\nD: %.1f%s\n"), FRACTION(entry->sec, 60), depthvalue, depth_unit);
|
||||||
for (cyl = 0; cyl < MAX_CYLINDERS; cyl++) {
|
for (cyl = 0; cyl < MAX_CYLINDERS; cyl++) {
|
||||||
int mbar = GET_PRESSURE(entry, cyl);
|
int mbar = get_plot_pressure(entry, cyl);
|
||||||
if (!mbar)
|
if (!mbar)
|
||||||
continue;
|
continue;
|
||||||
struct gasmix mix = displayed_dive.cylinder[cyl].gasmix;
|
struct gasmix mix = displayed_dive.cylinder[cyl].gasmix;
|
||||||
|
@ -1595,7 +1595,7 @@ void compare_samples(struct plot_data *e1, struct plot_data *e2, char *buf, int
|
||||||
bar_used = 0;
|
bar_used = 0;
|
||||||
|
|
||||||
last_sec = start->sec;
|
last_sec = start->sec;
|
||||||
last_pressure = GET_PRESSURE(start, 0);
|
last_pressure = get_plot_pressure(start, 0);
|
||||||
|
|
||||||
data = start;
|
data = start;
|
||||||
while (data != stop) {
|
while (data != stop) {
|
||||||
|
@ -1616,12 +1616,12 @@ void compare_samples(struct plot_data *e1, struct plot_data *e2, char *buf, int
|
||||||
if (data->depth > max_depth)
|
if (data->depth > max_depth)
|
||||||
max_depth = data->depth;
|
max_depth = data->depth;
|
||||||
/* Try to detect gas changes - this hack might work for some side mount scenarios? */
|
/* Try to detect gas changes - this hack might work for some side mount scenarios? */
|
||||||
if (GET_PRESSURE(data, 0) < last_pressure + 2000)
|
if (get_plot_pressure(data, 0) < last_pressure + 2000)
|
||||||
bar_used += last_pressure - GET_PRESSURE(data, 0);
|
bar_used += last_pressure - get_plot_pressure(data, 0);
|
||||||
|
|
||||||
count += 1;
|
count += 1;
|
||||||
last_sec = data->sec;
|
last_sec = data->sec;
|
||||||
last_pressure = GET_PRESSURE(data, 0);
|
last_pressure = get_plot_pressure(data, 0);
|
||||||
}
|
}
|
||||||
avg_depth /= stop->sec - start->sec;
|
avg_depth /= stop->sec - start->sec;
|
||||||
avg_speed /= stop->sec - start->sec;
|
avg_speed /= stop->sec - start->sec;
|
||||||
|
@ -1670,13 +1670,13 @@ void compare_samples(struct plot_data *e1, struct plot_data *e2, char *buf, int
|
||||||
const char *volume_unit;
|
const char *volume_unit;
|
||||||
struct plot_data *first = start;
|
struct plot_data *first = start;
|
||||||
struct plot_data *last = stop;
|
struct plot_data *last = stop;
|
||||||
while (first < stop && GET_PRESSURE(first, 0) == 0)
|
while (first < stop && get_plot_pressure(first, 0) == 0)
|
||||||
first++;
|
first++;
|
||||||
while (last > first && GET_PRESSURE(last, 0) == 0)
|
while (last > first && get_plot_pressure(last, 0) == 0)
|
||||||
last--;
|
last--;
|
||||||
|
|
||||||
pressure_t first_pressure = { GET_PRESSURE(first, 0) };
|
pressure_t first_pressure = { get_plot_pressure(first, 0) };
|
||||||
pressure_t stop_pressure = { GET_PRESSURE(last, 0) };
|
pressure_t stop_pressure = { get_plot_pressure(last, 0) };
|
||||||
int volume_used = gas_volume(cyl, first_pressure) - gas_volume(cyl, stop_pressure);
|
int volume_used = gas_volume(cyl, first_pressure) - gas_volume(cyl, stop_pressure);
|
||||||
|
|
||||||
/* Mean pressure in ATM */
|
/* Mean pressure in ATM */
|
||||||
|
|
|
@ -99,7 +99,12 @@ int get_maxdepth(struct plot_info *pi);
|
||||||
#define INTERPOLATED_PR 1
|
#define INTERPOLATED_PR 1
|
||||||
#define SENSOR_PRESSURE(_entry,_idx) (_entry)->pressure[_idx][SENSOR_PR]
|
#define SENSOR_PRESSURE(_entry,_idx) (_entry)->pressure[_idx][SENSOR_PR]
|
||||||
#define INTERPOLATED_PRESSURE(_entry,_idx) (_entry)->pressure[_idx][INTERPOLATED_PR]
|
#define INTERPOLATED_PRESSURE(_entry,_idx) (_entry)->pressure[_idx][INTERPOLATED_PR]
|
||||||
#define GET_PRESSURE(_entry,_idx) (SENSOR_PRESSURE(_entry,_idx) ? SENSOR_PRESSURE(_entry,_idx) : INTERPOLATED_PRESSURE(_entry,_idx))
|
|
||||||
|
static inline int get_plot_pressure(const struct plot_data *entry, int idx)
|
||||||
|
{
|
||||||
|
int res = SENSOR_PRESSURE(entry, idx);
|
||||||
|
return res ? res : INTERPOLATED_PRESSURE(entry, idx);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -669,7 +669,7 @@ void DiveGasPressureItem::modelDataChanged(const QModelIndex &topLeft, const QMo
|
||||||
struct plot_data *entry = dataModel->data().entry + i;
|
struct plot_data *entry = dataModel->data().entry + i;
|
||||||
|
|
||||||
for (int cyl = 0; cyl < MAX_CYLINDERS; cyl++) {
|
for (int cyl = 0; cyl < MAX_CYLINDERS; cyl++) {
|
||||||
int mbar = GET_PRESSURE(entry, cyl);
|
int mbar = get_plot_pressure(entry, cyl);
|
||||||
int time = entry->sec;
|
int time = entry->sec;
|
||||||
|
|
||||||
if (!mbar)
|
if (!mbar)
|
||||||
|
@ -729,7 +729,7 @@ void DiveGasPressureItem::modelDataChanged(const QModelIndex &topLeft, const QMo
|
||||||
struct plot_data *entry = dataModel->data().entry + i;
|
struct plot_data *entry = dataModel->data().entry + i;
|
||||||
|
|
||||||
for (int cyl = 0; cyl < MAX_CYLINDERS; cyl++) {
|
for (int cyl = 0; cyl < MAX_CYLINDERS; cyl++) {
|
||||||
int mbar = GET_PRESSURE(entry, cyl);
|
int mbar = get_plot_pressure(entry, cyl);
|
||||||
|
|
||||||
if (!mbar)
|
if (!mbar)
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Add table
Reference in a new issue