+struct lzms_lz_lru_queue {
+ u32 recent_offsets[LZMS_NUM_RECENT_OFFSETS + 1];
+ u32 prev_offset;
+ u32 upcoming_offset;
+};
+
+static void
+lzms_init_lz_lru_queue(struct lzms_lz_lru_queue *queue)
+{
+ for (int i = 0; i < LZMS_NUM_RECENT_OFFSETS + 1; i++)
+ queue->recent_offsets[i] = i + 1;
+
+ queue->prev_offset = 0;
+ queue->upcoming_offset = 0;
+}
+
+static void
+lzms_update_lz_lru_queue(struct lzms_lz_lru_queue *queue)
+{
+ if (queue->prev_offset != 0) {
+ for (int i = LZMS_NUM_RECENT_OFFSETS - 1; i >= 0; i--)
+ queue->recent_offsets[i + 1] = queue->recent_offsets[i];
+ queue->recent_offsets[0] = queue->prev_offset;
+ }
+ queue->prev_offset = queue->upcoming_offset;
+}
+