From 6a23fa268e7ffcb016bb79f475a39b628b998b24 Mon Sep 17 00:00:00 2001 From: Stedd Date: Sun, 1 Dec 2024 17:29:02 +0100 Subject: [PATCH] Small gain in performance from reserving space I don't want to hardcode the number of lines in the input file. --- days/day01.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/days/day01.cpp b/days/day01.cpp index a5f7b90..607950c 100644 --- a/days/day01.cpp +++ b/days/day01.cpp @@ -156,6 +156,10 @@ void day01::Part2() std::unordered_map 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");