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
Merged

Conversation

@isiahmeadows
Copy link
Member

@isiahmeadows isiahmeadows commented Aug 28, 2018

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
@isiahmeadows
Copy link
Member Author

@isiahmeadows isiahmeadows commented Sep 14, 2018

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

@isiahmeadows isiahmeadows force-pushed the isiahmeadows:simplify-removal branch 4 times, most recently from 3e8890e to 4d2bbfc Sep 19, 2018
@isiahmeadows
Copy link
Member Author

@isiahmeadows isiahmeadows commented Sep 19, 2018

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

while (--count) {
removeNodeFromDOM(dom.nextSibling)
var parent = vnode.dom.parentNode
if (parent != null) {

This comment has been minimized.

@StephanHoyer

StephanHoyer Sep 19, 2018
Member

Out of curiosity: how can this happen?

This comment has been minimized.

@StephanHoyer

StephanHoyer Sep 19, 2018
Member

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

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

This comment has been minimized.

@isiahmeadows

isiahmeadows Sep 19, 2018
Author Member

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.

This comment has been minimized.

@isiahmeadows

isiahmeadows Sep 19, 2018
Author Member

Done.

@isiahmeadows isiahmeadows force-pushed the isiahmeadows:simplify-removal branch from 4d2bbfc to 85c19fa Sep 19, 2018
@isiahmeadows
Copy link
Member Author

@isiahmeadows isiahmeadows commented Sep 19, 2018

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

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

@StephanHoyer StephanHoyer commented Sep 21, 2018

LGTM

@isiahmeadows isiahmeadows merged commit 62eb081 into MithrilJS:next Sep 22, 2018
1 check passed
1 check passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@isiahmeadows isiahmeadows deleted the isiahmeadows:simplify-removal branch Sep 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants