Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve the menu builder class #1277

Merged
merged 2 commits into from
May 11, 2024

Conversation

dfsmania
Copy link
Collaborator

@dfsmania dfsmania commented May 6, 2024

Question Answer
Pull request type ENHANCEMENT
License MIT

What's in this PR?

Improve the menu builder internal logic. Previously, the menu was recompiled completely each time a call to the methods addAfter(), addBefore() and addIn() was performed, and the recompilation was done against an already compiled version of the menu, this was not so good at performance. Also, there were some bugs when removing an active item from a nested submenu, since the menu was not recompiled and the root submenu containing that item remainded active.

We can solve all these issues by keeping a raw (uncompiled) version of the menu internally, and with a flag to indicate that the menu needs a recompilation after issuing one or multiple calls to the methods that changes the menu. This way the compiled version of the menu may be generated only when the client tries to access it, or when the client tries to access an old compiled version of the menu.

In this PR we apply the previous ideas to the menu builder, and we cover the bugs mentioned with some additional tests. Also we add a better documentation to the code.

Checklist

  • I tested these changes.

@dfsmania dfsmania requested a review from resslinger May 6, 2024 03:00
@dfsmania dfsmania merged commit 15b5b8b into jeroennoten:master May 11, 2024
34 checks passed
@dfsmania dfsmania deleted the improve_menu_builder branch May 11, 2024 20:37
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.

2 participants