From f315ebdd5c7a30284c67e47273eb784dd19b3879 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre-Marie=20P=C3=A9drot?= Date: Thu, 22 Oct 2020 17:25:20 +0200 Subject: [PATCH] Micro-optimization in Control.check_for_interrupt. We do not have to increase the step counter when out of the threaded mode since this counter is only relevant when in that mode. --- lib/control.ml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/control.ml b/lib/control.ml index bb42b5727e37..95ea3935a7e2 100644 --- a/lib/control.ml +++ b/lib/control.ml @@ -18,10 +18,12 @@ let enable_thread_delay = ref false let check_for_interrupt () = if !interrupt then begin interrupt := false; raise Sys.Break end; - incr steps; - if !enable_thread_delay && !steps = 1000 then begin - Thread.delay 0.001; - steps := 0; + if !enable_thread_delay then begin + incr steps; + if !steps = 1000 then begin + Thread.delay 0.001; + steps := 0; + end end (** This function does not work on windows, sigh... *)