Make renumber scratch runtime-owned #50

Merged
andrew merged 3 commits from 12 into main 2026-08-06 12:40:37 -04:00
Collaborator

Closes #12

Moves RENUMBER and target-prescan scratch storage into akbasic_Runtime, rewrites lines through one runtime-owned scratch line, and applies the mapping with in-place permutation cycles. The preflight and error behavior remain unchanged.

Verification: cmake --build build-34 --parallel 2; ctest --test-dir build-34 --output-on-failure (113/113 passed).

Closes #12 Moves RENUMBER and target-prescan scratch storage into akbasic_Runtime, rewrites lines through one runtime-owned scratch line, and applies the mapping with in-place permutation cycles. The preflight and error behavior remain unchanged. Verification: cmake --build build-34 --parallel 2; ctest --test-dir build-34 --output-on-failure (113/113 passed).
logikoma added 1 commit 2026-08-05 18:37:16 -04:00
Make renumber scratch runtime-owned
Some checks failed
akbasic CI Build / cmake_build (push) Successful in 4m21s
akbasic CI Build / akgl_build (push) Failing after 12m38s
akbasic CI Build / coverage (push) Failing after 12m56s
akbasic CI Build / sanitizers (push) Failing after 13m5s
akbasic CI Build / mutation_test (push) Successful in 18m7s
e20fd445a4
Co-authored-by: Andrew Kesterson <andrew@starfort.tech>
logikoma requested review from andrew 2026-08-05 18:37:23 -04:00
andrew requested changes 2026-08-05 18:46:52 -04:00
@@ -384,0 +389,4 @@
if ( map[i] < 0 || obj->renumber_visited[i] ) {
continue;
}
PASS(errctx, aksl_memcpy(&displaced, &obj->source[i], sizeof(displaced)));
Owner

Couldn't all of these aksl_memcpy calls in this loop be aksl_strncpy() calls sized to AKBASIC_MAX_LINE_LENGTH? That would be faster, since very few lines will fill all of the bytes in their line. We don't actually care if everything in the line gets initialized to zero, we just want the new null-terminated string in there. This would save cycles.

Couldn't all of these `aksl_memcpy` calls in this loop be `aksl_strncpy()` calls sized to `AKBASIC_MAX_LINE_LENGTH`? That would be faster, since very few lines will fill all of the bytes in their line. We don't actually care if *everything* in the line gets initialized to zero, we just want the new null-terminated string in there. This would save cycles.
Owner

@logikoma Couldn't all of these aksl_memcpy calls in this loop be aksl_strncpy() calls sized to AKBASIC_MAX_LINE_LENGTH? That would be faster, since very few lines will fill all of the bytes in their line. We don't actually care if everything in the line gets initialized to zero, we just want the new null-terminated string in there. This would save cycles.

@logikoma Couldn't all of these aksl_memcpy calls in this loop be aksl_strncpy() calls sized to AKBASIC_MAX_LINE_LENGTH? That would be faster, since very few lines will fill all of the bytes in their line. We don't actually care if everything in the line gets initialized to zero, we just want the new null-terminated string in there. This would save cycles.
Owner

@logikoma Convert all of these aksl_memcpy calls in this loop to aksl_strncpy() calls sized to AKBASIC_MAX_LINE_LENGTH. That would be faster, since very few lines will fill all of the bytes in their line. We don't actually care if everything in the line gets initialized to zero, we just want the new null-terminated string in there. This would save cycles.

@logikoma Convert all of these aksl_memcpy calls in this loop to aksl_strncpy() calls sized to AKBASIC_MAX_LINE_LENGTH. That would be faster, since very few lines will fill all of the bytes in their line. We don't actually care if everything in the line gets initialized to zero, we just want the new null-terminated string in there. This would save cycles.
andrew marked this conversation as resolved
logikoma was assigned by andrew 2026-08-06 12:07:42 -04:00
andrew reviewed 2026-08-06 12:08:32 -04:00
@@ -384,0 +396,4 @@
obj->renumber_visited[current] = 1;
if ( destination == i ) {
displaced.lineno = destination;
PASS(errctx, aksl_memcpy(&obj->source[destination], &displaced,
Owner

@logikoma Convert all of these aksl_memcpy calls in this function to aksl_strncpy() calls sized to AKBASIC_MAX_LINE_LENGTH. That would be faster, since very few lines will fill all of the bytes in their line. We don't actually care if everything in the line gets initialized to zero, we just want the new null-terminated string in there. This would save cycles.

@logikoma Convert all of these aksl_memcpy calls in this function to aksl_strncpy() calls sized to AKBASIC_MAX_LINE_LENGTH. That would be faster, since very few lines will fill all of the bytes in their line. We don't actually care if everything in the line gets initialized to zero, we just want the new null-terminated string in there. This would save cycles.
logikoma added 1 commit 2026-08-06 12:38:01 -04:00
Use bounded string copies when renumbering
Some checks failed
akbasic CI Build / akgl_build (push) Has been cancelled
akbasic CI Build / mutation_test (push) Has been cancelled
akbasic CI Build / coverage (push) Has been cancelled
akbasic CI Build / cmake_build (push) Has been cancelled
akbasic CI Build / sanitizers (push) Has been cancelled
6896df1dff
Author
Collaborator

Implemented in 6896df1: RENUMBER now copies line text with aksl_strncpy() bounded by AKBASIC_MAX_LINE_LENGTH, while explicitly preserving lineno and numbered metadata during the in-place permutation. Verified with ctest --test-dir build-review50 -R '^renumber$' --output-on-failure (1/1 passed).

Implemented in 6896df1: RENUMBER now copies line text with aksl_strncpy() bounded by AKBASIC_MAX_LINE_LENGTH, while explicitly preserving lineno and numbered metadata during the in-place permutation. Verified with ctest --test-dir build-review50 -R '^renumber$' --output-on-failure (1/1 passed).
andrew added 1 commit 2026-08-06 12:40:24 -04:00
Merge branch 'main' into 12
Some checks failed
akbasic CI Build / cmake_build (push) Successful in 3m30s
akbasic CI Build / sanitizers (push) Successful in 4m53s
akbasic CI Build / coverage (push) Successful in 3m55s
akbasic CI Build / akgl_build (push) Has been cancelled
akbasic CI Build / mutation_test (push) Has been cancelled
899476c6dd
andrew merged commit 1decfd878d into main 2026-08-06 12:40:37 -04:00
andrew deleted branch 12 2026-08-06 12:40:39 -04:00
Sign in to join this conversation.