Skip to content

Commit e59ec45

Browse files
committed
Use slightly more correct variable names
1 parent 9bb8f71 commit e59ec45

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

inst/include/cpp11/protect.hpp

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -255,30 +255,31 @@ static struct {
255255

256256
PROTECT(obj);
257257

258-
static SEXP list_ = get_preserve_list();
258+
static SEXP list = get_preserve_list();
259259

260-
// Get references to head, tail of the precious list.
261-
SEXP head = list_;
262-
SEXP tail = CDR(list_);
260+
// Get references to the head of the precious list and the next element
261+
// after the head
262+
SEXP head = list;
263+
SEXP next = CDR(list);
263264

264-
// Add a new cell that points to the current head + tail.
265-
SEXP cell = PROTECT(Rf_cons(head, tail));
265+
// Add a new cell that points to the current head + next.
266+
SEXP cell = PROTECT(Rf_cons(head, next));
266267
SET_TAG(cell, obj);
267268

268-
// Update the head + tail to point at the newly-created cell,
269-
// effectively inserting that cell between the current head + tail.
269+
// Update the head + next to point at the newly-created cell,
270+
// effectively inserting that cell between the current head + next.
270271
SETCDR(head, cell);
271-
SETCAR(tail, cell);
272+
SETCAR(next, cell);
272273

273274
UNPROTECT(2);
274275

275276
return cell;
276277
}
277278

278279
void print() {
279-
static SEXP list_ = get_preserve_list();
280-
for (SEXP head = list_; head != R_NilValue; head = CDR(head)) {
281-
REprintf("%x CAR: %x CDR: %x TAG: %x\n", head, CAR(head), CDR(head), TAG(head));
280+
static SEXP list = get_preserve_list();
281+
for (SEXP cell = list; cell != R_NilValue; cell = CDR(cell)) {
282+
REprintf("%x CAR: %x CDR: %x TAG: %x\n", cell, CAR(cell), CDR(cell), TAG(cell));
282283
}
283284
REprintf("---\n");
284285
}

0 commit comments

Comments
 (0)