vendredi 4 décembre 2015

Reading value from buffer efficiently

I have a std::vector<char> buffer in memory with a number at a specific offset, e.g.

00 00 00 00 00 00 00 00 00 33 2E 31 34 99 99 99 .........3.14™™™

I know the end and start offset to read the double/float value, but right now I'm copying the relevant part with std::copy() into a std::string and then calling std::stod. My question is: how can I make this faster?

There must be a way to avoid the copy.. for instance: can I point a stream to a specific offset in another buffer? Or something similar perhaps

Aucun commentaire:

Enregistrer un commentaire