+ /* The subinterval at POS has been used up. Move on to the next
+ position. */
+ if (++hist->pos == DLSPEED_HISTORY_SIZE)
+ hist->pos = 0;
+
+ /* Invalidate old data (from the previous cycle) at this
+ position. */
+ hist->summed_times -= hist->times[hist->pos];
+ hist->summed_bytes -= hist->bytes[hist->pos];
+ hist->times[hist->pos] = delta_time;
+ hist->bytes[hist->pos] = howmuch;
+ }
+ else
+ {
+ /* Increment the data at POS. */
+ hist->times[hist->pos] += delta_time;
+ hist->bytes[hist->pos] += howmuch;
+ }
+
+ hist->summed_times += delta_time;
+ hist->summed_bytes += howmuch;
+ hist->previous_time = dltime;
+
+#if 0
+ /* Sledgehammer check that summed_times and summed_bytes are
+ accurate. */
+ {
+ int i;
+ long sumt = 0, sumb = 0;
+ for (i = 0; i < DLSPEED_HISTORY_SIZE; i++)
+ {
+ sumt += hist->times[i];
+ sumb += hist->bytes[i];
+ }
+ assert (sumt == hist->summed_times);
+ assert (sumb == hist->summed_bytes);
+ }
+#endif
+
+ if (screen_width - 1 != bp->width)
+ {
+ bp->width = screen_width - 1;