From 1c1133ce8258dad367aad3b7c8eee0083aecf772 Mon Sep 17 00:00:00 2001 From: eunhhu Date: Mon, 19 Oct 2026 07:59:15 +0100 Subject: A list value of numbers copied whole (140's LIST_VALUE review, no new opcode, no change to what a module means): nest() made every list value item by item into a new tree (64 ns an item, 250 ns a copy fixed); an event's list in FLAT arrays, not keyed, its cells numbers, bools and integers, is now copied column by column (pure_list_copied: 600 items 38,268 to 985 ns, 60 items 3,926 to 324); UAX #14's nine lists a line 6,917 to 6,445 ns a code point (-6.8%, the same instructions); JSON tree's, HTTP's and inflate's (trees: texts or lists in their records, or few) as they were; copied_lists in test-module (random lists against item by item, then each changed apart; trees, keys and texts not copied so) --- core/module-list.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'core/module-list.c') diff --git a/core/module-list.c b/core/module-list.c index 2f2c359..91dd378 100644 --- a/core/module-list.c +++ b/core/module-list.c @@ -1800,6 +1800,30 @@ bool pure_list_arrays(PureList *list) { unsigned pure_list_form(const PureList *list) { return list->form; } +PureList *pure_list_copied(const PureList *from) { + const Layout *l = &from->layout; + if (from->form != FLAT || !from->arrays || from->pack || from->copy || l->key >= 0) return NULL; + for (unsigned f = 0; f < l->fields; ++f) + if (pure_cell_text(l->kinds[f]) || l->kinds[f] == PURE_CELL_LIST) return NULL; + PureList *list = pure_list_new(l->fields, l->kinds); + if (!list || !pure_list_arrays(list)) { + pure_list_free(list); + return NULL; + } + for (unsigned f = 0; f < l->fields; ++f) { /* its widths as they are: narrowed or widened by what it holds */ + list->width[f] = from->width[f]; + if (!from->count || !from->width[f]) continue; + if (!(list->columns[f] = malloc(from->count * from->width[f]))) { + pure_list_free(list); + return NULL; + } + memcpy(list->columns[f], from->columns[f], from->count * from->width[f]); + } + list->count = list->room = from->count; + list->bytes = from->bytes; + return list; +} + bool pure_list_cells(PureList *list, PureCells *out) { if (list->form != FLAT && !(list->form == DENSE && pure_list_full(list))) return false; const Layout *l = &list->layout; -- cgit v1.2.3