Pārlūkot izejas kodu

Merge pull request #2771 from laytan/fix-queue-reserve

fix queue reserve always doubling in size when there is enough space
Jeroen van Rijn 2 gadi atpakaļ
vecāks
revīzija
ac4e259e29
1 mainītis faili ar 1 papildinājumiem un 1 dzēšanām
  1. 1 1
      core/container/queue/queue.odin

+ 1 - 1
core/container/queue/queue.odin

@@ -56,7 +56,7 @@ space :: proc(q: $Q/Queue($T)) -> int {
 
 // Reserve enough space for at least the specified capacity
 reserve :: proc(q: ^$Q/Queue($T), capacity: int) -> runtime.Allocator_Error {
-	if uint(capacity) > q.len {
+	if capacity > space(q^) {
 		return _grow(q, uint(capacity)) 
 	}
 	return nil