# HG changeset patch # User mjsousa # Date 1623016360 -3600 # Node ID 4f584251c73d64a82abdfac37d6ce178207f0a18 # Parent cadd89d14ca500a93d1886f4113750a658b034db optimization: normalize buffer when it becomes empty after data purge diff -r cadd89d14ca5 -r 4f584251c73d mb_ds_util.h --- a/mb_ds_util.h Sun Jun 06 22:40:06 2021 +0100 +++ b/mb_ds_util.h Sun Jun 06 22:52:40 2021 +0100 @@ -152,10 +152,10 @@ static inline u8 *lb_data_purge(lb_buf_t *buf, int count) { buf->data_start += count + buf->marked_for_purge; buf->marked_for_purge = 0; - if (buf->data_start > buf->data_end) - buf->data_start = buf->data_end; - if ((buf->data_end == buf->data_size) || (buf->data_start >= buf->max_data_start)) + if (buf->data_start >= buf->data_end) + buf->data_start = buf->data_end = 0; // no bytes in buffer, might just as well normalize it + else if ((buf->data_end == buf->data_size) || (buf->data_start >= buf->max_data_start)) return lb_normalize(buf); return buf->data + buf->data_start;