3 ms·
Ok, so pre-allocating then. That's sort of equivalent to new StringBuffer(9), except java uses the heap. Safe types doesn't stop you from doing this. You do ne
by Too 8y ago
Ok, so pre-allocating then. That's sort of equivalent to new StringBuffer(9), except java uses the heap.
Safe types doesn't stop you from doing this. You do need another length-field though, one for the allocated size and one for the used size. In c++, std::string already has this feature with the reserve/capacity functions, STL is also heap based but it is possible with some effort to pass it a stack allocator. Now c++ isn't exactly the best reference when it comes to these things either but just saying conceptually fat pointers doesn't stop you from doing these things, see WalterBrights reply for a better example.