2 ms·
I've written APIs that require extra bytes. The exact requirements can be complex to explain, so to minimize complexity I would just put the maximum over-buffer
by sagarm 6y ago
I've written APIs that require extra bytes. The exact requirements can be complex to explain, so to minimize complexity I would just put the maximum over-buffer size in the function docs.
As for _why_: knowing that you have a buffer of at least a certain size can allow you to avoid bounds checks, branches, and allocations. For hot loops this can result in a significant performance improvement.