From 6da2a740ac40a13c4e2b6b24701c4a6effa9c893 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Amaury=20S=C3=A9chet?= Date: Wed, 27 Nov 2024 23:27:17 +0000 Subject: [PATCH] [GC] Better early return in maybeRunGCCycle. --- sdlib/d/gc/tcache.d | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/sdlib/d/gc/tcache.d b/sdlib/d/gc/tcache.d index 5cd6ac70f..01ba825aa 100644 --- a/sdlib/d/gc/tcache.d +++ b/sdlib/d/gc/tcache.d @@ -603,7 +603,7 @@ private: bool maybeRunGCCycle() { // If the GC is disabled or we have not reached the point // at which we try to collect, move on. - if (!enableGC || allocated < nextGCRun) { + if (likely(allocated < nextGCRun) || !enableGC) { return false; } @@ -613,12 +613,11 @@ private: return false; } + nextGCRun = allocated + BlockSize; + import d.gc.collector; auto collector = Collector(&this); - auto didRun = collector.maybeRunGCCycle(); - - nextGCRun = allocated + BlockSize; - return didRun; + return collector.maybeRunGCCycle(); } /**