I have a program that reads data from a file line-by-line. I would like to copy some substring of that line in to a map as below:
std::map< DWORD, std::string > my_map;
DWORD index; // populated with some data
char buffer[ 1024 ]; // populated with some data
char* element_begin; // points to some location in buffer
char* element_end; // points to some location in buffer > element_begin
my_map.insert( std::make_pair( index, std::string( element_begin, element_end ) ) );
This std::map<>::insert()
operation takes a long time (It doubles the file parsing time). Is there a way to make this a less expensive operation?
Thanks, PaulH
Edit: to be more specific, I want to know that I'm doing the minimum number of copy operations to get the data from the file in to the map.