# # patch "ChangeLog" # from [ea0771fdc5b6c4c00a82ab99650c159f69d5a5f6] # to [2f887b65ea3bf040cd3ddae7ca42adf926d2aad5] # # patch "file_io.cc" # from [ab7652248f7318010eadb5e2040e324eb8d09013] # to [d55aef64c0bca487d6f902437167531ee4c647f5] # --- ChangeLog +++ ChangeLog @@ -179,6 +179,11 @@ * database.cc (database::load): Load and execute dump in chunks, fixes bug 13570. +2005-07-01 Eric Anderson + + * file_io.cc: Pre-allocate space for the file read so that the + string doesn't have to be incrementally expanded during the read. + 2005-07-01 Matthew Gregan * tests/t_cvsimport_drepper2.at: Canonicalise monotone output so --- file_io.cc +++ file_io.cc @@ -401,9 +401,12 @@ ifstream file(p.string().c_str(), ios_base::in | ios_base::binary); - string in; if (!file) throw oops(string("cannot open file ") + p.string() + " for reading"); + + string in; + size_t filesize = fs::file_size(p); + in.reserve(filesize+1); // +1 for '\0' if someone uses c_str() on this CryptoPP::FileSource f(file, true, new CryptoPP::StringSink(in)); dat = in; }