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.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'core/module.c') diff --git a/core/module.c b/core/module.c index 3a6c4b5..f970daf 100644 --- a/core/module.c +++ b/core/module.c @@ -2668,10 +2668,11 @@ static uint64_t nest(PureApp *app, uint32_t record, const PureList *from) { app->nested.shared = shared; app->nested.capacity = capacity; } - PureList *list = new_list(m, record, false); - if (!list) return 0; + PureList *list = from && !m->record_nested[record] ? pure_list_copied(from) : NULL; /* numbers in arrays: at once */ + size_t at = list ? pure_list_count(from) : 0; + if (!list && !(list = new_list(m, record, false))) return 0; const PureRecord *r = &m->record[record]; - for (size_t at = 0, count = from ? pure_list_count(from) : 0; at < count; ++at) { + for (size_t count = from ? pure_list_count(from) : 0; at < count; ++at) { PureCell cells[PURE_RECORD_FIELDS]; for (unsigned f = 0; f < r->count; ++f) cells[f] = pure_list_get(from, at, f); if (pure_list_insert(list, at, cells, NULL) != PURE_OK) { pure_list_free(list); return 0; } -- cgit v1.2.3