I have a file I'm reading into a vector<char> buffer, reading through it for keywords, and adding new lines between old lines at those keywords. Currently, I'm doing the reading in what I believe is the least ideal way, by reading character per character, and checking after the new line character.
I could use strings to just make this much simpler. The only problem is I'm using a C library, and have to frequently convert my strings to C strings. So, going forward I'm trying to use C strings in the spots where most of the heavy lifting is done to make replacing the default String implementation less of a headache once all the functionality is in.
I know Is there a built in means of reading a vector<char> buffer line by line? Will it work if I need to resize the buffer after an insertion?
I'm going to make the code multithreaded, and from what I've read char * perform much better, since they get tossed on the stack. I also want to avoid frequent calls to c_str(). The full code is for a parser generating Unreal Game code that I would prefer to have scale well for larger data sets.
I'm going to make the code multithreaded, and from what I've read char * perform much better, since they get tossed on the stack.
The issues are the same with multi-threading whether you manage the memory manually or a container (such as std::string) does it for you.
You should avoid advice on optimization when you don't know whether or not it matters. Yes, using a stack based memory scheme is more performant than using std::string.. but does it matter? And if it does, why not use a custom allocator instead?
I also want to avoid frequent calls to c_str().
Again, why? It costs nothing in terms of performance.
For me this is mostly a learning exercise. A custom allocator would definitely be ideal. I do plan on implementing that down the line. I'll most likely be making a stack allocator.
The big reason why I want to avoid the standard library is I'm interested in going into Gameplay or Game Engine programming. For various reasons in game programing the standard library is avoided, mostly historical reasons at this point. The biggest arguments I currently find valid are for reducing binary size, and compile times for large projects. I've been working a decent amount with Unreal, which doesn't support the standard library, but does use templates heavily.
I'd like to ween myself off of relying on templates mainly since using them slows compile times down significantly.