MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / rec_finalize_index_cell

Function rec_finalize_index_cell

internal/cbm/sqlite_writer.c:499–511  ·  view source on GitHub ↗

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.

Source from the content-addressed store, hash-verified

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.
499static 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.

Calls 5

rec_payload_lenFunction · 0.85
varint_lenFunction · 0.85
cells_allocFunction · 0.85
put_varintFunction · 0.85
rec_writeFunction · 0.85

Tested by

no test coverage detected