I have a legacy code that receives some proprietary, parses it and creates a bunch of static char arrays (embedded in class representing the message), to represent NULL strings. Afterwards pointers to the string are passed all around and finally serialized to some buffer.
Profiling shows that str*()
methods take a lot of time.
Therefore I would like to use memcpy()
whether it's possible. To achive it I need a way to associate length with pointer to NULL terminating string. I though about:
Using
std::string
looks less efficient, since it requires memory allocation and thread synchronization.I can use
std::pair<pointer to string, length>
. But in this case I need to maintain length "manually".
What do you think?