Re:How fast can you allocate a large block of memory in C++?
by unlinked_dll on Wednesday January 15, 2020 @11:57PM
(#22061778)
Eh I'd say using malloc in place of new is more code smell than anything here. If you want a byte array make a byte array
If you don't know how big you want the byte array make a vector.
It's baffling to me how many C++ developers don't use the standard collections. The only one that really sucks is unordered_map.
[ Parent
| on HN ]
Re:How fast can you allocate a large block of memory in C++?
by vardump on Thursday January 16, 2020 @02:18AM
(#22062309)
Small vectors are also bad. There should be some kind of small vector optimization, just like what is common for std::string.
Re:How fast can you allocate a large block of memory in C++?
by mgraczyk on Thursday January 16, 2020 @01:31AM
(#22062152)
vector<bool> also sucks
Re:How fast can you allocate a large block of memory in C++?
by unlinked_dll on Thursday January 16, 2020 @01:35AM
(#22062170)
That's fair. But in my experience that's rather rare and easy to work around.