quote:Original post by Ready4Dis
Ahh, but I wrote my own string class that I use in my game engine. The buffer allocates extra space for when adding stuff into the string, thereby not needing to re-allocate the buffer each time it's added to . So, i am uber elite
I have to agree with antareus and Fruny here.
The above quote just proves their point even further, std::string already gives you the ability to reserve memory.
std::string example;example.reserve(1000); //reserve memory for 1000 characters
You could also just write another allocator for std::basic_string to allocate more memory than needed (although most implementations of the standard allocator already do this anyway).
Its just another example of over optimization gone crazy, writing your own string class to do something you could do very simply with std::basic_string, which is written and tested by the most experienced C++ programmers in the world.
quote:
Yes, for this simply filling it in with a trivial std::string::find/replace would have been extremely simplistic, but later if it wasn't fast enough, he'd have to go through his program and change over all the std::strings with char arrays, or a custom string class, change all function prototypes, replace any function that he used strings in, etc. It'd be twice as much work replacing all that crap as it would to just write it with speed in mind in the first place.
Or a far more likely situation would be that you end up writing your own string class (ready4dis::string) and using that instead, only to find that it is full of bugs and causing serious problems in your software. You then have to go back and replace every ready4dis::string with std::basic_string.
[edited by - Jingo on November 15, 2003 12:44:31 PM]