mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Profile: turn INSERT_ENTRY macro into helper function
The only apparent reason that this was a macro is that it automatically increased the "index" and "entry" counts. But incrementing these explicitly seems reasonable. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
2fd4cb5fe1
commit
7e1425796d
1 changed files with 25 additions and 17 deletions
|
@ -493,17 +493,19 @@ static void calculate_max_limits_new(struct dive *dive, struct divecomputer *giv
|
||||||
/* copy the previous entry (we know this exists), update time and depth
|
/* copy the previous entry (we know this exists), update time and depth
|
||||||
* and zero out the sensor pressure (since this is a synthetic entry)
|
* and zero out the sensor pressure (since this is a synthetic entry)
|
||||||
* increment the entry pointer and the count of synthetic entries. */
|
* increment the entry pointer and the count of synthetic entries. */
|
||||||
#define INSERT_ENTRY(_time, _depth, _sac) \
|
static void insert_entry(struct plot_info *pi, int idx, int time, int depth, int sac)
|
||||||
*entry = entry[-1]; \
|
{
|
||||||
entry->sec = _time; \
|
struct plot_data *entry = pi->entry + idx;
|
||||||
entry->depth = _depth; \
|
struct plot_data *prev = pi->entry + idx - 1;
|
||||||
entry->running_sum = (entry - 1)->running_sum + (_time - (entry - 1)->sec) * (_depth + (entry - 1)->depth) / 2; \
|
*entry = *prev;
|
||||||
memset(entry->pressure, 0, sizeof(entry->pressure)); \
|
entry->sec = time;
|
||||||
entry->sac = _sac; \
|
entry->depth = depth;
|
||||||
entry->ndl = -1; \
|
entry->running_sum = prev->running_sum + (time - prev->sec) * (depth + prev->depth) / 2;
|
||||||
entry->bearing = -1; \
|
memset(entry->pressure, 0, sizeof(entry->pressure));
|
||||||
entry++; \
|
entry->sac = sac;
|
||||||
idx++
|
entry->ndl = -1;
|
||||||
|
entry->bearing = -1;
|
||||||
|
}
|
||||||
|
|
||||||
void free_plot_info_data(struct plot_info *pi)
|
void free_plot_info_data(struct plot_info *pi)
|
||||||
{
|
{
|
||||||
|
@ -562,12 +564,16 @@ static void populate_plot_entries(struct dive *dive, struct divecomputer *dc, st
|
||||||
|
|
||||||
/* Add events if they are between plot entries */
|
/* Add events if they are between plot entries */
|
||||||
while (ev && (int)ev->time.seconds < lasttime + offset) {
|
while (ev && (int)ev->time.seconds < lasttime + offset) {
|
||||||
INSERT_ENTRY(ev->time.seconds, interpolate(lastdepth, depth, ev->time.seconds - lasttime, delta), sac);
|
insert_entry(pi, idx, ev->time.seconds, interpolate(lastdepth, depth, ev->time.seconds - lasttime, delta), sac);
|
||||||
|
entry++;
|
||||||
|
idx++;
|
||||||
ev = ev->next;
|
ev = ev->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* now insert the time interpolated entry */
|
/* now insert the time interpolated entry */
|
||||||
INSERT_ENTRY(lasttime + offset, interpolate(lastdepth, depth, offset, delta), sac);
|
insert_entry(pi, idx, lasttime + offset, interpolate(lastdepth, depth, offset, delta), sac);
|
||||||
|
entry++;
|
||||||
|
idx++;
|
||||||
|
|
||||||
/* skip events that happened at this time */
|
/* skip events that happened at this time */
|
||||||
while (ev && (int)ev->time.seconds == lasttime + offset)
|
while (ev && (int)ev->time.seconds == lasttime + offset)
|
||||||
|
@ -576,7 +582,9 @@ static void populate_plot_entries(struct dive *dive, struct divecomputer *dc, st
|
||||||
|
|
||||||
/* Add events if they are between plot entries */
|
/* Add events if they are between plot entries */
|
||||||
while (ev && (int)ev->time.seconds < time) {
|
while (ev && (int)ev->time.seconds < time) {
|
||||||
INSERT_ENTRY(ev->time.seconds, interpolate(lastdepth, depth, ev->time.seconds - lasttime, delta), sac);
|
insert_entry(pi, idx, ev->time.seconds, interpolate(lastdepth, depth, ev->time.seconds - lasttime, delta), sac);
|
||||||
|
entry++;
|
||||||
|
idx++;
|
||||||
ev = ev->next;
|
ev = ev->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -628,8 +636,10 @@ static void populate_plot_entries(struct dive *dive, struct divecomputer *dc, st
|
||||||
int time = ev->time.seconds;
|
int time = ev->time.seconds;
|
||||||
|
|
||||||
if (time > lasttime) {
|
if (time > lasttime) {
|
||||||
INSERT_ENTRY(ev->time.seconds, 0, 0);
|
insert_entry(pi, idx, ev->time.seconds, 0, 0);
|
||||||
lasttime = time;
|
lasttime = time;
|
||||||
|
idx++;
|
||||||
|
entry++;
|
||||||
}
|
}
|
||||||
ev = ev->next;
|
ev = ev->next;
|
||||||
}
|
}
|
||||||
|
@ -640,8 +650,6 @@ static void populate_plot_entries(struct dive *dive, struct divecomputer *dc, st
|
||||||
pi->nr = idx;
|
pi->nr = idx;
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef INSERT_ENTRY
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calculate the sac rate between the two plot entries 'first' and 'last'.
|
* Calculate the sac rate between the two plot entries 'first' and 'last'.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Reference in a new issue