From 55f2534f1933af0c70eeab5ce106fb888e51c0cc Mon Sep 17 00:00:00 2001 From: crosire Date: Tue, 8 Jan 2019 15:16:58 +0100 Subject: [PATCH] Ignore duplicated file modifications in a span of three seconds Fixes #13 --- source/blink.cpp | 6 ++++++ source/blink.hpp | 1 + 2 files changed, 7 insertions(+) diff --git a/source/blink.cpp b/source/blink.cpp index 615e8b0..b78fbae 100644 --- a/source/blink.cpp +++ b/source/blink.cpp @@ -249,6 +249,12 @@ void blink::application::run() if (source_file.extension() != ".cpp") continue; + // Ignore duplicated notifications by comparing times and skipping any changes that are not older than 3 seconds + if (const auto current_time = GetTickCount(); _last_modifications[source_file.string()] + 3000 > current_time) + continue; + else + _last_modifications[source_file.string()] = current_time; + print("Detected modification to: " + source_file.string()); // Build compiler command line diff --git a/source/blink.hpp b/source/blink.hpp index a0c1378..37dba29 100644 --- a/source/blink.hpp +++ b/source/blink.hpp @@ -36,5 +36,6 @@ namespace blink std::vector _object_files; std::vector> _source_files; std::unordered_map _symbols; + std::unordered_map _last_modifications; }; }