mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-16 00:12:51 +00:00
AyStar: Use dbg_assert in BinaryHeap Push, GetElement
This commit is contained in:
parent
ad90f90d43
commit
dd1bd270e7
@ -84,11 +84,11 @@ void BinaryHeap::Free(bool free_values)
|
|||||||
bool BinaryHeap::Push(void *item, int priority)
|
bool BinaryHeap::Push(void *item, int priority)
|
||||||
{
|
{
|
||||||
if (this->size == this->max_size) return false;
|
if (this->size == this->max_size) return false;
|
||||||
assert(this->size < this->max_size);
|
dbg_assert(this->size < this->max_size);
|
||||||
|
|
||||||
if (this->elements[this->size >> BINARY_HEAP_BLOCKSIZE_BITS] == nullptr) {
|
if (this->elements[this->size >> BINARY_HEAP_BLOCKSIZE_BITS] == nullptr) {
|
||||||
/* The currently allocated blocks are full, allocate a new one */
|
/* The currently allocated blocks are full, allocate a new one */
|
||||||
assert((this->size & BINARY_HEAP_BLOCKSIZE_MASK) == 0);
|
dbg_assert((this->size & BINARY_HEAP_BLOCKSIZE_MASK) == 0);
|
||||||
this->elements[this->size >> BINARY_HEAP_BLOCKSIZE_BITS] = MallocT<BinaryHeapNode>(BINARY_HEAP_BLOCKSIZE);
|
this->elements[this->size >> BINARY_HEAP_BLOCKSIZE_BITS] = MallocT<BinaryHeapNode>(BINARY_HEAP_BLOCKSIZE);
|
||||||
this->blocks++;
|
this->blocks++;
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ struct BinaryHeap {
|
|||||||
*/
|
*/
|
||||||
inline BinaryHeapNode &GetElement(uint i)
|
inline BinaryHeapNode &GetElement(uint i)
|
||||||
{
|
{
|
||||||
assert(i > 0);
|
dbg_assert(i > 0);
|
||||||
return this->elements[(i - 1) >> BINARY_HEAP_BLOCKSIZE_BITS][(i - 1) & BINARY_HEAP_BLOCKSIZE_MASK];
|
return this->elements[(i - 1) >> BINARY_HEAP_BLOCKSIZE_BITS][(i - 1) & BINARY_HEAP_BLOCKSIZE_MASK];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user