Explorar el Código

Merge pull request #761 from Tetralux/patch-7

Reuse container.Queue capacity when calling pop_front()
gingerBill hace 4 años
padre
commit
ce35de47e4
Se han modificado 1 ficheros con 3 adiciones y 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;
 }