Explorar o código

Merge pull request #761 from Tetralux/patch-7

Reuse container.Queue capacity when calling pop_front()
gingerBill %!s(int64=4) %!d(string=hai) anos
pai
achega
ce35de47e4
Modificáronse 1 ficheiros con 3 adicións e 0 borrados
  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;
 }