Skip to content

Commit

Permalink
Replace always false checks with assertions (#2065)
Browse files Browse the repository at this point in the history
A view of the cycle detector can never refer to a NULL actor.
  • Loading branch information
Benoit Vey authored and jemc committed Jul 20, 2017
1 parent 255c24b commit 392bca6
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/libponyrt/gc/cycle.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ static pony_actor_t* cycle_detector;

static view_t* get_view(detector_t* d, pony_actor_t* actor, bool create)
{
pony_assert(actor != NULL);

view_t key;
key.actor = actor;
size_t index = HASHMAP_UNKNOWN;
Expand Down Expand Up @@ -252,7 +254,7 @@ static void apply_delta(detector_t* d, view_t* view)

static bool mark_grey(detector_t* d, view_t* view, size_t rc)
{
if(!view->blocked || (view->actor == NULL))
if(!view->blocked)
return false;

// apply any stored reference delta
Expand Down Expand Up @@ -299,7 +301,7 @@ static void scan_grey(detector_t* d, view_t* view, size_t rc)

static bool mark_black(view_t* view, size_t rc, int* count)
{
if(!view->blocked || (view->actor == NULL))
if(!view->blocked)
{
pony_assert(view->color == COLOR_BLACK);
return false;
Expand Down

0 comments on commit 392bca6

Please sign in to comment.