Skip to content

Commit

Permalink
do not execute root NULL check in the beginning of dd_cov_update_cove…
Browse files Browse the repository at this point in the history
…rage
  • Loading branch information
anmarchenko committed May 16, 2024
1 parent 209337c commit c653d17
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions ext/datadog_cov/datadog_cov.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,6 @@ static void dd_cov_update_coverage(rb_event_flag_t event, VALUE data, VALUE self
struct dd_cov_data *dd_cov_data;
TypedData_Get_Struct(data, struct dd_cov_data, &dd_cov_data_type, dd_cov_data);

if (dd_cov_data->root == NULL)
{
return;
}

int captured_frames = rb_profile_frames(
0 /* stack starting depth */,
1, /* number of stack frames to return */
Expand All @@ -144,14 +139,14 @@ static void dd_cov_update_coverage(rb_event_flag_t event, VALUE data, VALUE self

// skip if we cover the same file again
uintptr_t current_filename_ptr = (uintptr_t)c_filename;
if (dd_cov_data->last_filename_ptr == (uintptr_t)current_filename_ptr)
if (dd_cov_data->last_filename_ptr == current_filename_ptr)
{
return;
}
dd_cov_data->last_filename_ptr = current_filename_ptr;

// if given filename is not located under the root, we skip it
if (is_prefix(dd_cov_data->root, dd_cov_data->root_len, c_filename) == 0)
if (dd_cov_data->root_len == 0 || is_prefix(dd_cov_data->root, dd_cov_data->root_len, c_filename) == 0)
{
return;
}
Expand Down

0 comments on commit c653d17

Please sign in to comment.