aboutsummaryrefslogtreecommitdiffstats
path: root/core/module.c
diff options
context:
space:
mode:
authoreunhhu <[email protected]>2026-10-05 07:53:22 +0100
committereunhhu <[email protected]>2026-10-05 07:53:22 +0100
commit6c641903b089d81fb193c3949ccc677b701bc55b (patch)
tree31aa8442c04bebeccb414838ebccf186ea5eb062 /core/module.c
parent2dc0a4df9485c0a4c08859ad81f41d6efab98dd5 (diff)
downloadpure-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.c')
-rw-r--r--core/module.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/core/module.c b/core/module.c
index ff6f131..c486d45 100644
--- a/core/module.c
+++ b/core/module.c
@@ -2788,7 +2788,7 @@ static inline __attribute__((always_inline)) int step(Frame *frame, const PureOp
if (status == PURE_INVALID) status = pure_list_insert(list, at, cells, undo_for(app, arg));
arena->used = mark;
if (status != PURE_OK) REFUSED;
- move_indices(m, values, arg, pure_list_count(list), at, true);
+ if (m->state_indexed[arg]) move_indices(m, values, arg, pure_list_count(list), at, true);
if (!grows(app, before, list_held(app, list))) { kind = PURE_FAULT_MEMORY; FAILED; }
NEXT;
}
@@ -2798,7 +2798,7 @@ static inline __attribute__((always_inline)) int step(Frame *frame, const PureOp
if ((status = pure_list_remove(app->lists[arg], at, undo_for(app, arg))) != PURE_OK) REFUSED;
/* the item goes, its cells kept to undo and its record to save */
if (!grows(app, before, list_held(app, app->lists[arg]))) { kind = PURE_FAULT_MEMORY; FAILED; }
- move_indices(m, values, arg, pure_list_count(app->lists[arg]), at, false);
+ if (m->state_indexed[arg]) move_indices(m, values, arg, pure_list_count(app->lists[arg]), at, false);
if (ev->walk && ev->walk->list == arg) { /* the walk goes on with the item after */
if (at < ev->walk->at) --ev->walk->at;
else if (at == ev->walk->at) ev->walk->removed = true;
@@ -3049,6 +3049,22 @@ int pure_run_loop(Frame *frame, uint32_t pc) {
void pure_run_break(Frame *frame) { (void)leave_loop(frame); }
+int pure_run_item(Frame *frame, uint32_t pc) {
+ const PureOp *op = &frame->m->code[pc];
+ const PureList *list = frame->app->lists[list_of(op->arg)];
+ size_t at = (size_t)frame->stack[frame->sp - 1].num;
+ PureRun run;
+ if (at < pure_list_count(list) && !pure_list_form(list) && pure_list_run(list, at, &run)) {
+ uint64_t id;
+ frame->run.list = list;
+ pure_list_stamp(list, &id, &frame->run.version);
+ frame->run.start = run.start, frame->run.count = run.count;
+ for (unsigned f = 0; f < 16; ++f) frame->run.columns[f] = run.column[f].numbers;
+ }
+ uint32_t next;
+ return step(frame, op, pc, &next);
+}
+
int pure_run_iterate(Frame *frame) {
uint32_t next = UINT32_MAX;
int how = iterate(frame, &next);