An index leaf cell, varint(payload_len) + record, written in place: building the record first and copying it into the cell was a second allocation and a copy for every index entry (16 M record buffers of pure churn on the Go corpus, waste sanitizer 2026-09-17). Same bytes.
| 497 | // copy for every index entry (16 M record buffers of pure churn on the Go |
| 498 | // corpus, waste sanitizer 2026-09-17). Same bytes. |
| 499 | static uint8_t *rec_finalize_index_cell(const RecordBuilder *r, int *out_len) { |
| 500 | *out_len = 0; |
| 501 | int payload_len = rec_payload_len(r); |
| 502 | int total = varint_len(payload_len) + payload_len; |
| 503 | uint8_t *cell = cells_alloc((size_t)total); |
| 504 | if (!cell) { |
| 505 | return NULL; |
| 506 | } |
| 507 | int pos = put_varint(cell, payload_len); |
| 508 | pos += rec_write(r, cell + pos); |
| 509 | *out_len = pos; |
| 510 | return cell; |
| 511 | } |
| 512 | |
| 513 | // --- Page builder --- |
| 514 | // Accumulates cells (records) into B-tree leaf pages. |
no test coverage detected