redcarpet icon indicating copy to clipboard operation
redcarpet copied to clipboard

Only increase the size of the stack if required

Open tessereth opened this issue 6 years ago • 0 comments

Hi! I was looking through this code for unrelated reasons and happened to notice that redcarpet_stack_push is calling redcarpet_stack_grow significantly more often than necessary. My assumption from reading the code is that it should only allocate more memory if their's insufficient space but this is increasing the buffer size on every push so there's always double the space required.

Your contributing guide says to add a test but as far as I can tell there's no way to test C code directly so I'm not sure that's a feasible thing to do in this case. Please let me know if there is a way to test this and I'd be happy to add it. This does not appear to effect the benchmark in any way.

tessereth avatar Jan 27 '19 02:01 tessereth