Parse the command list once - #107
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_commandson its own withap_getword, and each loop testedcmds < unparsed_commands + strlen(unparsed_commands), so it calledstrlenon 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 testpasses all 267 cases; the commands run in the same order with the same arguments, so no golden file changes.make -C test valgrindreports no module allocation lost; the list lives in the request pool.