Closed yurivish closed 9 months ago
This branching probability hint reduces the difference in the execution time between the success case and the OOM case. The effect depends on the specific platform, optimization level, and other build options. You can measure the effect on your platform.
Hello! Thank you for publishing this code – I'm learning a lot from it! I noticed a line in
o1heapAllocate
that made me curious:https://github.com/pavel-kirienko/o1heap/blob/aa3c253923db36eee7d73a4a5e30884a5fe7a6eb/o1heap/o1heap.c#L376
If I understand correctly, this conditional checks for allocation failure with an allocation size greater than zero. In practice, we expect most allocations to succeed. If the purpose of
O1HEAP_LIKELY
is to signal to the compiler that an expression is likely to be true, why is this a good place to putO1HEAP_LIKELY
?It seems to me that that
amount > 0
is likely, butout == NULL
is not, and so the conjunction is unlikely.