Showing 2 of 3 files from the diff.
Newly tracked file
src/lib/c-utils.h changed.
Other files ignored by Codecov
NEWS.md has changed.

@@ -1,6 +1,7 @@
Loading
1 1
#ifndef RLANG_C_UTILS_H
2 2
#define RLANG_C_UTILS_H
3 3
4 +
#include <float.h>
4 5
#include "cnd.h"
5 6
6 7
@@ -69,9 +70,39 @@
Loading
69 70
r_ssize r_ssize_min(r_ssize x, r_ssize y) {
70 71
  return (y < x) ? y : x;
71 72
}
73 +
72 74
static inline
73 75
r_ssize r_ssize_max(r_ssize x, r_ssize y) {
74 76
  return (y < x) ? x : y;
75 77
}
76 78
79 +
static inline
80 +
double r_ssize_as_double(r_ssize x) {
81 +
  if (x > DBL_MAX || x < -DBL_MAX) {
82 +
    r_stop_internal("r_ssize_as_double", "Result can't be represented as `double`.");
83 +
  }
84 +
85 +
  return (double) x;
86 +
}
87 +
88 +
static inline
89 +
r_ssize r_double_as_ssize(double x) {
90 +
  if (x > R_SSIZE_MAX || x < R_SSIZE_MIN) {
91 +
    r_stop_internal("r_ssize_as_double", "Result can't be represented as `r_ssize`.");
92 +
  }
93 +
94 +
  return (r_ssize) x;
95 +
}
96 +
97 +
static inline
98 +
double r_double_mult(double x, double y) {
99 +
  double out = x * y;
100 +
101 +
  if (!isfinite(out)) {
102 +
    r_stop_internal("r_double_mult", "Can't multiply double values.");
103 +
  }
104 +
105 +
  return out;
106 +
}
107 +
77 108
#endif

@@ -160,14 +160,14 @@
Loading
160 160
  sexp* data_mask;
161 161
162 162
  if (bottom == r_null) {
163 -
    bottom = KEEP(r_new_environment(r_empty_env, 0));
163 +
    bottom = KEEP(r_new_environment(r_empty_env, 100));
164 164
    data_mask = bottom;
165 165
  } else {
166 166
    check_data_mask_input(bottom, "bottom");
167 167
    // Create a child because we don't know what might be in `bottom`
168 168
    // and we need to clear its contents without deleting any object
169 169
    // created in the data mask environment
170 -
    data_mask = KEEP(r_new_environment(bottom, 0));
170 +
    data_mask = KEEP(r_new_environment(bottom, 100));
171 171
  }
172 172
173 173
  if (top == r_null) {
@@ -271,6 +271,7 @@
Loading
271 271
}
272 272
273 273
static sexp* data_pronoun_sym = NULL;
274 +
static r_ssize mask_length(r_ssize n);
274 275
275 276
sexp* rlang_as_data_mask(sexp* data) {
276 277
  if (mask_info(data).type == RLANG_MASK_DATA) {
@@ -304,7 +305,9 @@
Loading
304 305
    check_unique_names(data);
305 306
306 307
    sexp* names = r_names(data);
307 -
    bottom = KEEP_N(r_new_environment(r_empty_env, 0), n_protect);
308 +
309 +
    r_ssize n_mask = mask_length(r_length(data));
310 +
    bottom = KEEP_N(r_new_environment(r_empty_env, n_mask), n_protect);
308 311
309 312
    if (names != r_null) {
310 313
      r_ssize n = r_length(data);
@@ -335,6 +338,12 @@
Loading
335 338
  return data_mask;
336 339
}
337 340
341 +
static
342 +
r_ssize mask_length(r_ssize n) {
343 +
  r_ssize n_grown = r_double_as_ssize(r_double_mult(r_ssize_as_double(n), 1.05));
344 +
  return r_ssize_max(n_grown, r_ssize_add(n, 20));
345 +
}
346 +
338 347
// For compatibility of the exported C callable
339 348
// TODO: warn
340 349
sexp* rlang_new_data_mask_compat(sexp* bottom, sexp* top, sexp* parent) {
Files Coverage
R 83.67%
src 88.64%
Project Totals (112 files) 86.22%
1
comment: false
2

3
coverage:
4
  status:
5
    patch:
6
      default:
7
        target: 0
8
        threshold: 100
9
    project:
10
      default:
11
        target: 70
12
        threshold: 100
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading