diff options
| author | eunhhu <[email protected]> | 2026-10-05 07:53:22 +0100 |
|---|---|---|
| committer | eunhhu <[email protected]> | 2026-10-05 07:53:22 +0100 |
| commit | 6c641903b089d81fb193c3949ccc677b701bc55b (patch) | |
| tree | 31aa8442c04bebeccb414838ebccf186ea5eb062 /core/module-list.c | |
| parent | 2dc0a4df9485c0a4c08859ad81f41d6efab98dd5 (diff) | |
| download | pure-6c641903b089d81fb193c3949ccc677b701bc55b.tar.gz pure-6c641903b089d81fb193c3949ccc677b701bc55b.zip | |
Read a tree's items in compiled code from a run the frame keeps, start a run at the finger's leaf, and move indices only for a list an index refers to (021)
- The frame keeps the run compiled code read a tree's item from last (the
list as it was: its version); an item it holds is read from its column,
else pure_run_item takes the item's run and steps.
- pure_list_run starts at the leaf the finger keeps when it holds the
position (a slice found by key just before): no second descent; the
run after it is found from the root (PureRun.pathless).
- LIST_APPEND and LIST_REMOVE move index states only for a list one
refers to.
- A search (core only): 89 ms compiled (answers the executor's).
Diffstat (limited to 'core/module-list.c')
| -rw-r--r-- | core/module-list.c | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/core/module-list.c b/core/module-list.c index 7bf05e1..b3a9ed3 100644 --- a/core/module-list.c +++ b/core/module-list.c @@ -1137,7 +1137,8 @@ unsigned pure_list_form(const PureList *list) { return list->form; } const size_t pure_list_layout[] = { [LIST_COUNT_AT] = offsetof(PureList, count), [LIST_MEMBERS_AT] = offsetof(PureList, members), [LIST_MEMBER_CAPACITY_AT] = offsetof(PureList, member_capacity), [LIST_BITMAP_AT] = offsetof(PureList, bitmap), - [LIST_FORM_AT] = offsetof(PureList, form), [LIST_COLUMNS_AT] = offsetof(PureList, columns)}; + [LIST_FORM_AT] = offsetof(PureList, form), [LIST_COLUMNS_AT] = offsetof(PureList, columns), + [LIST_VERSION_AT] = offsetof(PureList, version)}; bool pure_list_lookup(const PureList *list, unsigned key_field, PureCell key, unsigned field, PureCell *cell) { bool found; @@ -1757,6 +1758,7 @@ static void open_array_run(const PureList *list, size_t at, PureRun *run) { run->start = at; run->count = list->form == DENSE ? 1 : (unsigned)(list->count - at < PURE_LIST_RUN ? list->count - at : PURE_LIST_RUN); run->depth = 0; + run->pathless = false; for (unsigned f = 0; f < l->fields; ++f) if (pure_cell_text(l->kinds[f])) run->column[f].texts = (const PureSpan *)list->columns[f] + row; else if (l->kinds[f] == PURE_CELL_INTEGER) run->column[f].integers = (const int64_t *)list->columns[f] + row; @@ -1772,6 +1774,16 @@ bool pure_list_run(const PureList *list, size_t at, PureRun *run) { return true; } } + size_t within; + const Node *kept = fingered(list, at, &within); /* a slice's first item, found by key just before */ + if (kept) { + run->path[0] = kept; + run->depth = 0; + run->pathless = true; /* the run after it found from the root */ + run->start = at - within; + open_run(&list->layout, kept, run); + return true; + } const Node *node = list->root; size_t start = 0; unsigned depth = 0; @@ -1785,6 +1797,7 @@ bool pure_list_run(const PureList *list, size_t at, PureRun *run) { run->path[depth] = node; run->depth = depth; run->start = start; + run->pathless = false; open_run(&list->layout, node, run); return true; } @@ -1798,6 +1811,23 @@ bool pure_list_next(const PureList *list, PureRun *run) { open_array_run(list, run->start + run->count, run); return true; } + if (run->pathless) { /* the next from the root, with its path */ + size_t at = run->start + run->count; + if (at >= list->count) return false; + const Node *node = list->root; + size_t start = 0; + unsigned depth = 0; + while (!node->leaf) { + unsigned i = child_at(node, at - start); + start += guide(node)->before[i]; + run->path[depth] = node; + run->taken[depth++] = (uint8_t)i; + node = child(node, i); + } + run->path[depth] = node, run->depth = depth, run->start = start, run->pathless = false; + open_run(&list->layout, node, run); + return true; + } size_t start = run->start + run->count; unsigned depth = run->depth; while (depth && run->taken[depth - 1] + 1u >= ((const Node *)run->path[depth - 1])->count) --depth; |
