perf: List.equals as a loop #204

Closed
opened 2026-10-08 14:25:24 +00:00 by orion · 1 comment
Collaborator

Goal

List.equals in std/collections/src/list.trb is indexed().all { ... }, an iterator and a closure per item. Make it a plain loop (length check first, then compare slot by slot).

Design record

PERFORMANCE.md 9.6 ("List.equals is an iterator and a closure per item"). Part of #144.

Acceptance criteria

  • List.equals is a loop; behaviour is unchanged (same result for equal, unequal, different-length and empty lists), covered by a test in std/collections.
  • sh tools/gates.sh a is green in forge CI.
  • torb check compiler and torb build --emit-c tests/conformance/adts.trb are not slower than on main (alternating runs, see below).
  • The before/after numbers are added to PERFORMANCE.md (new section 9.7).

Measurement

Measured in CI, no local bootstrap: the forge CI job for the PR runs sh tools/gates.sh a; the before/after processor times come from torb check tests/conformance/adts.trb, torb build --emit-c tests/conformance/adts.trb and torb build --emit-c ./compiler run with the main binary and the PR binary alternating (3 runs, mean, as in PERFORMANCE.md 9.5), printed in the CI log and copied into PERFORMANCE.md 9.7. CI machines are noisy, so the ratio of alternating runs counts, not absolute seconds.

Seed impact

None: no new native, syntax or looked-up name. The change alters the C of every program that compares lists (std change), which is expected and not breaking. One PR, one perf(std): commit.

## Goal `List.equals` in `std/collections/src/list.trb` is `indexed().all { ... }`, an iterator and a closure per item. Make it a plain loop (length check first, then compare slot by slot). ## Design record [PERFORMANCE.md 9.6](https://git.torb.dev/torbscript/language/src/branch/main/docs/PERFORMANCE.md) ("List.equals is an iterator and a closure per item"). Part of #144. ## Acceptance criteria - [ ] `List.equals` is a loop; behaviour is unchanged (same result for equal, unequal, different-length and empty lists), covered by a test in `std/collections`. - [ ] `sh tools/gates.sh a` is green in forge CI. - [ ] `torb check compiler` and `torb build --emit-c tests/conformance/adts.trb` are not slower than on `main` (alternating runs, see below). - [ ] The before/after numbers are added to PERFORMANCE.md (new section 9.7). ## Measurement Measured in CI, no local bootstrap: the forge CI job for the PR runs `sh tools/gates.sh a`; the before/after processor times come from `torb check tests/conformance/adts.trb`, `torb build --emit-c tests/conformance/adts.trb` and `torb build --emit-c ./compiler` run with the `main` binary and the PR binary alternating (3 runs, mean, as in PERFORMANCE.md 9.5), printed in the CI log and copied into PERFORMANCE.md 9.7. CI machines are noisy, so the ratio of alternating runs counts, not absolute seconds. ## Seed impact None: no new native, syntax or looked-up name. The change alters the C of every program that compares lists (std change), which is expected and not breaking. One PR, one `perf(std):` commit.
Author
Collaborator

[loop:torbscript] claim implement by session:loop-torbscript-20261008 until 2026-10-08T20:26Z

[loop:torbscript] claim implement by session:loop-torbscript-20261008 until 2026-10-08T20:26Z
argus closed this issue 2026-10-08 16:33:43 +00:00
Sign in to join this conversation.
No labels
loop
ready
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
torbscript/language#204
No description provided.