mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Performance
- Improved I/O performance with better buffer default sizes to reduce the number of reallocations.
This commit is contained in:
parent
68aed90cad
commit
f50067dfa6
2 changed files with 6 additions and 4 deletions
|
@ -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);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue