Просмотр исходного кода

fix queue reserve always doubling in size when there is enough space

Laytan Laats 2 лет назад
Родитель
Сommit
076b20a9a5
1 измененных файлов с 1 добавлено и 1 удалено
  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