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

isEmpty and other ways to avoid toString() calls #137

Merged
merged 1 commit into from Mar 19, 2018

Conversation

guybedford
Copy link
Contributor

This supports bundle.isEmpty() and source.isEmpty() to avoid the need to do a full bundle.toString().trim().length === 0 check.

Some other minor changes avoid unnecessary internal toString() calls.

Copy link
Collaborator

@mourner mourner left a comment

Choose a reason for hiding this comment

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

Looks great!

isEmpty () {
if (this.intro.length && this.intro.trim())
return false;
if (this.sources.some(source => !source.content.isEmpty()))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we avoid some in favor of simple for .. of loops? They also get transpiled into for loops by Buble here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ahh, I didn't know Buble would handle the transpilation here.

Could do, although at this order of loop it probably isn't much of a difference.

@mourner mourner merged commit c1c7930 into Rich-Harris:master Mar 19, 2018
@mourner
Copy link
Collaborator

mourner commented Mar 19, 2018

Published in v0.24.0.

@guybedford guybedford deleted the isEmpty branch March 19, 2018 15:37
@guybedford
Copy link
Contributor Author

Many thanks, it's a great help having this released for the incoming Rollup PR.

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