diff options
| author | eunhhu <[email protected]> | 2026-10-19 07:59:15 +0100 |
|---|---|---|
| committer | eunhhu <[email protected]> | 2026-10-19 07:59:15 +0100 |
| commit | 1c1133ce8258dad367aad3b7c8eee0083aecf772 (patch) | |
| tree | c939ae2e9ba6a2a220f1633fef107f9514ebb55b /core/module.c | |
| parent | f1bb9de4ac72136a1b0722ce77ac4ea6fd4fa413 (diff) | |
| download | pure-1c1133ce8258dad367aad3b7c8eee0083aecf772.tar.gz pure-1c1133ce8258dad367aad3b7c8eee0083aecf772.zip | |
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)
Diffstat (limited to 'core/module.c')
| -rw-r--r-- | core/module.c | 7 |
1 files changed, 4 insertions, 3 deletions
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; } |
