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

Simplify component removal #2214

Merged
merged 1 commit into from Sep 22, 2018

Conversation

dead-claudia
Copy link
Member

Description

Just a minor simplification of how elements are removed. It doesn't noticeably change performance, but it saves a few gzip'd bytes, and it avoids a function that was only really used for that one thing.

Motivation and Context

It just cleans up the code some.

How Has This Been Tested?

Ran all the unit tests and perf tests to check for regressions in both. Performance changes appear statistically insignificant.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation change

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I have updated docs/change-log.md

@dead-claudia
Copy link
Member Author

@MithrilJS/collaborators Can I get a review for this real quick?

@dead-claudia dead-claudia force-pushed the simplify-removal branch 4 times, most recently from 3e8890e to 4d2bbfc Compare September 19, 2018 06:20
@dead-claudia
Copy link
Member Author

I fixed the Git mess on my end - the history should be a lot cleaner and less polluted now.

render/render.js Outdated
while (--count) {
removeNodeFromDOM(dom.nextSibling)
var parent = vnode.dom.parentNode
if (parent != null) {
Copy link
Member

Choose a reason for hiding this comment

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

Out of curiosity: how can this happen?

Copy link
Member

Choose a reason for hiding this comment

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

I just tried to run the tests without this check. It worked.

Looks like this might only happen if the root-node is detached.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, the only way this can happen is if it's manually removed from the parent between oncreate and ondestroy and is the top node. I'll just remove it, because there's no valid reason to do that anyways.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

@dead-claudia
Copy link
Member Author

BTW, now the latest gain is about 30 bytes reclaimed min+gzip.

@dead-claudia dead-claudia force-pushed the simplify-removal branch 2 times, most recently from 4b5faf5 to 3afba13 Compare September 20, 2018 19:12
It's also a minor peephole optimization, but I saw bigger size wins, so
I'm citing that.
@StephanHoyer
Copy link
Member

LGTM

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.

None yet

2 participants