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

optimize generated code for if statements #28

Merged
merged 1 commit into from
Nov 30, 2016
Merged

optimize generated code for if statements #28

merged 1 commit into from
Nov 30, 2016

Conversation

Swatinem
Copy link
Member

This simplifies the generated code for if statements, also paving the road for simple else-if chains, via the two generated helper functions.

This also fixes the bug where the current code generates a duplicate elseBlock_0.update( changed, root );.

@codecov-io
Copy link

codecov-io commented Nov 28, 2016

Current coverage is 90.48% (diff: 100%)

Merging #28 into master will decrease coverage by 0.06%

@@             master        #28   diff @@
==========================================
  Files            49         48     -1   
  Lines          1291       1282     -9   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
- Hits           1169       1160     -9   
  Misses          122        122          
  Partials          0          0          

Powered by Codecov. Last update fd9dc90...64f8e77

@Swatinem
Copy link
Member Author

I rebased this with some further optimizations. This now pulls in all the conditions and blocks into a single if statement, which is really nice. And even for simple cases, the generated code for the if is a lot nicer.

Instead of walking elseif statements recursively, collect all the
conditions and blocks into a single if block
@Rich-Harris
Copy link
Member

Oh man, that is super smart. Took me a moment to get my head round it but that is really great. Amazing stuff

@Rich-Harris Rich-Harris merged commit 5a2e5c2 into sveltejs:master Nov 30, 2016
@Swatinem Swatinem deleted the optimize_if branch December 1, 2016 22:14
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.

3 participants