Skip to content

Commit

Permalink
[GC] Better early return in maybeRunGCCycle.
Browse files Browse the repository at this point in the history
  • Loading branch information
deadalnix committed Nov 27, 2024
1 parent 300ac03 commit 6da2a74
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions sdlib/d/gc/tcache.d
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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();
}

/**
Expand Down

0 comments on commit 6da2a74

Please sign in to comment.