Skip to content

Commit 27f0058

Browse files
committed
re-optimizes serialization
1 parent c201b67 commit 27f0058

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

NEWS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
#### Updates
44

5-
* Documentation updates.
5+
* Re-optimizes custom serialization (whilst addressing CRAN clang-UBSAN checks).
66

77
# nanonext 1.2.0
88

src/core.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ void nano_serialize_old(nano_buf *buf, const SEXP object, SEXP hook) {
245245
buf->buf[0] = 0x7;
246246
buf->buf[1] = (uint8_t) vec;
247247
buf->buf[2] = special_bit;
248-
buf->cur += 16;
248+
buf->cur += 12;
249249

250250
struct R_outpstream_st output_stream;
251251

@@ -268,7 +268,7 @@ void nano_serialize_old(nano_buf *buf, const SEXP object, SEXP hook) {
268268

269269
if (reg && TAG(hook) != R_NilValue) {
270270
const uint64_t cursor = (uint64_t) buf->cur;
271-
memcpy(buf->buf + 8, &cursor, sizeof(uint64_t));
271+
memcpy(buf->buf + 4, &cursor, sizeof(uint64_t));
272272
SEXP call, out;
273273

274274
if (vec) {
@@ -334,7 +334,7 @@ void nano_serialize(nano_buf *buf, const SEXP object, SEXP hook) {
334334
buf->buf[0] = 0x7;
335335
buf->buf[1] = (uint8_t) vec;
336336
buf->buf[3] = special_bit;
337-
buf->cur += 16;
337+
buf->cur += 12;
338338
}
339339

340340
struct R_outpstream_st output_stream;
@@ -358,7 +358,7 @@ void nano_serialize(nano_buf *buf, const SEXP object, SEXP hook) {
358358

359359
if (reg && TAG(hook) != R_NilValue) {
360360
const uint64_t cursor = (uint64_t) buf->cur;
361-
memcpy(buf->buf + 8, &cursor, sizeof(uint64_t));
361+
memcpy(buf->buf + 4, &cursor, sizeof(uint64_t));
362362
SEXP call, out;
363363

364364
if (vec) {
@@ -428,7 +428,7 @@ SEXP nano_unserialize(unsigned char *buf, const size_t sz, SEXP hook) {
428428
cur = 0;
429429
goto resume;
430430
case 0x7: ;
431-
memcpy(&offset, buf + 8, sizeof(uint64_t));
431+
memcpy(&offset, buf + 4, sizeof(uint64_t));
432432
if (offset) {
433433
SEXP raw, call;
434434
if (buf[1]) {
@@ -459,7 +459,7 @@ SEXP nano_unserialize(unsigned char *buf, const size_t sz, SEXP hook) {
459459
}
460460
SET_TAG(hook, reflist);
461461
}
462-
cur = 16;
462+
cur = 12;
463463
goto resume;
464464
}
465465
}

0 commit comments

Comments
 (0)