Performance

- Improved I/O performance with better buffer default sizes to reduce the
  number of reallocations.
This commit is contained in:
Paul Beckingham 2014-01-01 12:52:47 -05:00
parent 68aed90cad
commit f50067dfa6
2 changed files with 6 additions and 4 deletions

View file

@ -196,12 +196,13 @@ bool File::waitForLock ()
void File::read (std::string& contents)
{
contents = "";
contents.reserve (size ());
std::ifstream in (_data.c_str ());
if (in.good ())
{
std::string line;
line.reserve (1024);
line.reserve (512 * 1024);
while (getline (in, line))
contents += line + "\n";
@ -219,7 +220,7 @@ void File::read (std::vector <std::string>& contents)
if (in.good ())
{
std::string line;
line.reserve (1024);
line.reserve (512 * 1024);
while (getline (in, line))
contents.push_back (line);