浏览代码

Merge pull request #761 from Tetralux/patch-7

Reuse container.Queue capacity when calling pop_front()
gingerBill 4 年之前
父节点
当前提交
ce35de47e4
共有 1 个文件被更改,包括 3 次插入0 次删除
  1. 3 0
      core/container/queue.odin

+ 3 - 0
core/container/queue.odin

@@ -115,6 +115,9 @@ queue_pop_front :: proc(q: ^$Q/Queue($T)) -> T {
 	item := queue_get(q^, 0);
 	q.offset = (q.offset + 1) % array_len(q.data);
 	q.len -= 1;
+	if q.len == 0 {
+		q.offset = 0;
+	}
 	return item;
 }