Skip to content

Parse the command list once - #107

Merged
beetlebugorg merged 1 commit into
mainfrom
refactor/parse-commands-once
Aug 28, 2026
Merged

Parse the command list once#107
beetlebugorg merged 1 commit into
mainfrom
refactor/parse-commands-once

Conversation

@beetlebugorg

Copy link
Copy Markdown
Owner

What

The request commands are split into name and argument pairs one time, into d->commands, right after the request is verified. Four passes now read that list instead of walking the string themselves: the read-size hint, the command loop, the error-image geometry, and the watermark flatten check.

Why

Each pass parsed unparsed_commands on its own with ap_getword, and each loop tested cmds < unparsed_commands + strlen(unparsed_commands), so it called strlen on the whole string every iteration. The strings are short, so this is a cleanup rather than a measurable speedup: one parse, one list, read in four places.

Verify

make -C test test passes all 267 cases; the commands run in the same order with the same arguments, so no golden file changes. make -C test valgrind reports no module allocation lost; the list lives in the request pool.

Split unparsed_commands into name and argument pairs one time, into
d->commands, and read that list from dims_set_optimal_geometry,
dims_run_commands, dims_draw_error_image, and the watermark flatten check.

Each of those walked the string on its own, and the loop condition called
strlen on the whole string every iteration.
@beetlebugorg
beetlebugorg merged commit 8c982da into main Aug 28, 2026
5 checks passed
@beetlebugorg
beetlebugorg deleted the refactor/parse-commands-once branch August 28, 2026 20:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant