- /* don't start with a sac of 0 */
- int fe = i + 1;
- struct plot_data *future_entry = pi->entry + fe;
- while (fe < pi->nr && future_entry->sec - entry->sec < SAC_WINDOW) {
- fe++;
- future_entry = pi->entry + fe;
- }
- sac = GET_LOCAL_SAC(entry, future_entry, dive);
+ /* don't start with a sac of 0, so just calculate the first one */
+ sac = GET_LOCAL_SAC(entry, pi->entry + i + 1, dive);
+ }
+ } else {
+ int j;
+ sac = 0;
+ for (j = last; j < i; j++)
+ sac += GET_LOCAL_SAC(pi->entry + j, pi->entry + j + 1, dive);
+ sac /= (i - last);
+ if (entry->sec - last_entry->sec >= SAC_WINDOW) {
+ last++;
+ last_entry = pi->entry + last;