Reduce NullCommand nesting on the pausedCommands deque#14391
Merged
uckelman merged 2 commits intovassalengine:release-3.7from Apr 23, 2026
Merged
Reduce NullCommand nesting on the pausedCommands deque#14391uckelman merged 2 commits intovassalengine:release-3.7from
uckelman merged 2 commits intovassalengine:release-3.7from
Conversation
This minimizes the nesting of NullCommands on the deque.
Collaborator
|
Tagged this PR for next release; is anything holding it back ? |
Contributor
|
There aren't any tests demonstrating that behavior hasn't changed. |
Contributor
Author
|
Fair enough. I've added a unit test. It is a simpler example than the captured images show. Run this test on the existing code with a breakpoint at the end. Inspecting the command variable should show two NullCommands and a DisplayCommand. Note the nesting. With the change there should be a most one NullCommand regardless of the number of commands generated by DoActionButton. |
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.
While debugging another issue I noticed nesting of NullCommands. This is inefficient. The nesting means there are recursive descents for various methods.
The idiom for appending sub-commands to a command that may be a NullCommand is:
command = command.append(subcommand)The assignment turns the append into a replace when the command is a NullCommand. When the command is guaranteed not to be NullCommand, the assignment is not necessary.
This pull request pops the top element from the deque, appends the sub-command with an assignment and then pushes it back on the deque.
On this before image note the 5 NullCommands.

After only 1 NullCommand remains.
