redjack/libcork — pull request #82 by johnzachary (2014-02-12 22:00:52+00:00)
Title: Printing to cork buffers is inefficient

Functions that print to a cork_buffer end up calling `cork_buffer_append_vprintf`, which calls `vsnprintf` twice, once to get the size of the format string and another to print to the buffer. When the allocated buffer size is adequate to hold the format string, the first call to `vsnprintf` is unnecessary. This function can be made more efficient by calling `vsnprintf` to print and, if it fails, reallocate the cork buffer and try again.