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

Refactor WidgetPod::event. #1001

Merged
merged 3 commits into from
May 31, 2020
Merged

Refactor WidgetPod::event. #1001

merged 3 commits into from
May 31, 2020

Conversation

xStrom
Copy link
Member

@xStrom xStrom commented May 30, 2020

This PR is just the refactoring part of #986 so that we can get the refactoring in first and make the command targeting work more clear.

This new approach is more like WidgetPod::lifecycle. It doesn't copy/clone as much and is fewer lines of code allowing for easier understanding.

@xStrom xStrom added the S-needs-review waits for review label May 30, 2020
Copy link
Member

@cmyr cmyr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see the benefit. I'm a little hesitant about needs_merge; I think this method is getting to the point where we really want to start worrying about its complexity and the difficulty of reasoning about behaviour as we make changes in the future, and I think that it might be worth optimizing for reduced complexity at the cost of small runtime costs, and in the cases where merging would be skipped I expect skipping will be at best a verrrry small win?

// If we need to replace either the event or its data.
let mut modified_event = None;
// Tracking whether we need to merge our state up to the parent.
let mut needs_merge = false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this an optimization (my assumption), or are there times when merging would be incorrect?

if an optimization: my gut feeling is that merging is only a trivial amount of work in the general case, such that this optimization is unlikely to be meaningful even over very large graphs, and I'm not sure it's something it is worth adding more logic to handle, at least without being guided by a concrete performance concern?

@xStrom
Copy link
Member Author

xStrom commented May 31, 2020

I don' think the needs_merge adds any significant complexity, but I also don't think it's a significant performance win right now. So I removed it for clarity and added a comment about this situation.

Copy link
Member

@cmyr cmyr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great, thanks!

@xStrom xStrom removed the S-needs-review waits for review label May 31, 2020
@xStrom xStrom merged commit 2b6dd11 into linebender:master May 31, 2020
@xStrom xStrom deleted the event-refactor branch May 31, 2020 17:45
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