Small gain in performance from reserving space

I don't want to hardcode the number of lines in the input file.
This commit is contained in:
Stedd 2024-12-01 17:29:02 +01:00
parent 3d44c7c416
commit 6a23fa268e
1 changed files with 4 additions and 0 deletions

View File

@ -156,6 +156,10 @@ void day01::Part2()
std::unordered_map<int, int> occurrence_map;
int sum = 0;
size_t estimated_size = 1000;
col1.reserve(estimated_size);
occurrence_map.reserve(estimated_size);
std::ifstream input("input/day01.txt");
//std::ifstream input("input/day01short.txt");