4 ms·
There is a key difference in the 'long way' and 'stricky way' example in the readme - the 'long way' doesn't do any allocations and thus has a performance advan
by gkfasdfasdf 6y ago
There is a key difference in the 'long way' and 'stricky way' example in the readme - the 'long way' doesn't do any allocations and thus has a performance advantage out of the box. Also, where in the 'stricky way' does page get freed? This also needs to be shown in order to be equivalent to the 'long way'.
- wheybags 6y agoIf you look later on at the readme, you'll see that the stx_catf function does not reallocate, it truncates, there is another function for reallocating append. That said, I don't really see why one would need such a no-realloc function. In c++, I would just use std::string::reserve(some_big_num).
- gkfasdfasdf 6y agostx_new allocates the string, per the readme. My point is that the readme example is misleading, as the two code samples are not equivalent.
- alcover 6y agoYou are right, I changed it to malloc. This 'long way' thing is definitly not super useful..