From 1fdbf28378642a0392acbe1bc23fd96b602f4587 Mon Sep 17 00:00:00 2001 From: Joseph Birkner Date: Wed, 10 Dec 2025 12:17:12 +0100 Subject: [PATCH] Do not call slow (extremely slow on WASM) steady_clock when no timeout is set. --- include/simfil/environment.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/simfil/environment.h b/include/simfil/environment.h index 2a83b39..4ed5046 100644 --- a/include/simfil/environment.h +++ b/include/simfil/environment.h @@ -149,14 +149,14 @@ struct Context Phase phase = Evaluation; /* Timeout after which the evaluation should be canceled. */ - std::chrono::time_point timeout = std::chrono::time_point::max(); + std::optional> timeout; Context(Environment* env, Phase = Phase::Evaluation); auto canceled() const -> bool { - if (phase != Phase::Compilation) - return timeout < std::chrono::steady_clock::now(); + if (phase != Phase::Compilation && timeout) + return *timeout < std::chrono::steady_clock::now(); return false; } };