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

[Merged by Bors] - Removed some duplicate code, added ToIndentedString #2367

Closed
wants to merge 2 commits into from

Conversation

Razican
Copy link
Member

@Razican Razican commented Oct 22, 2022

In most cases, the ToInternedString was just calling self.to_indented_string(interner, 0). This avoids all this duplicate code by adding a new trait, ToIndentedString. Any type implementing that automatically implements ToInternedString.

I have also added a bunch of #[inline] in one-liners, and some one-line documentations for some functions.

I have noticed that we also use contains() and contains_arguments() a lot. Would it make sense to create traits for this?

@Razican Razican added enhancement New feature or request Internal Category for changelog labels Oct 22, 2022
@Razican Razican added this to the v0.17.0 milestone Oct 22, 2022
@github-actions
Copy link

github-actions bot commented Oct 22, 2022

Test262 conformance changes

Test result main count PR count difference
Total 93,383 93,383 0
Passed 69,114 69,114 0
Ignored 18,182 18,182 0
Failed 6,087 6,087 0
Panics 0 0 0
Conformance 74.01% 74.01% 0.00%

@codecov
Copy link

codecov bot commented Oct 22, 2022

Codecov Report

Merging #2367 (b73b429) into main (80017fd) will decrease coverage by 0.04%.
The diff coverage is 73.78%.

@@            Coverage Diff             @@
##             main    #2367      +/-   ##
==========================================
- Coverage   39.88%   39.84%   -0.05%     
==========================================
  Files         243      243              
  Lines       23293    23318      +25     
==========================================
  Hits         9290     9290              
- Misses      14003    14028      +25     
Impacted Files Coverage Δ
boa_engine/src/syntax/ast/expression/await.rs 8.33% <ø> (ø)
..._engine/src/syntax/ast/function/async_generator.rs 5.88% <0.00%> (ø)
boa_engine/src/syntax/ast/function/generator.rs 5.88% <0.00%> (ø)
boa_engine/src/syntax/ast/mod.rs 61.53% <ø> (ø)
boa_engine/src/syntax/ast/statement/labelled.rs 43.75% <ø> (ø)
boa_engine/src/syntax/ast/statement/switch/mod.rs 43.58% <28.57%> (-2.36%) ⬇️
...ne/src/syntax/ast/expression/literal/object/mod.rs 53.48% <33.33%> (+2.37%) ⬆️
boa_engine/src/syntax/ast/expression/mod.rs 39.39% <50.00%> (+1.15%) ⬆️
boa_interner/src/lib.rs 58.58% <50.00%> (+1.01%) ⬆️
boa_engine/src/syntax/ast/statement_list/mod.rs 62.50% <52.63%> (-2.96%) ⬇️
... and 26 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Copy link
Member

@raskad raskad left a comment

Choose a reason for hiding this comment

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

Looks like a great change to me!

Concerning contains and contains_arguments, I think we should leave those as-is for now. I had the idea of maybe generating the results at parse time and writing them into the AST so that we do not have to walk the AST every time we call those functions. I did not look at it seriously, but If something like that works out, we could remove all of those functions.

boa_interner/src/lib.rs Outdated Show resolved Hide resolved
Copy link
Member

@RageKnify RageKnify left a comment

Choose a reason for hiding this comment

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

LGTM, nothing to note

@Razican
Copy link
Member Author

Razican commented Oct 22, 2022

re-based :)

@raskad
Copy link
Member

raskad commented Oct 22, 2022

bors r+

bors bot pushed a commit that referenced this pull request Oct 22, 2022
In most cases, the `ToInternedString` was just calling `self.to_indented_string(interner, 0)`. This avoids all this duplicate code by adding a new trait, `ToIndentedString`. Any type implementing that automatically implements `ToInternedString`.

I have also added a bunch of `#[inline]` in one-liners, and some one-line documentations for some functions.

I have noticed that we also use `contains()` and `contains_arguments()` a lot. Would it make sense to create traits for this?
@bors
Copy link

bors bot commented Oct 22, 2022

Pull request successfully merged into main.

Build succeeded:

@bors bors bot changed the title Removed some duplicate code, added ToIndentedString [Merged by Bors] - Removed some duplicate code, added ToIndentedString Oct 22, 2022
@bors bors bot closed this Oct 22, 2022
@bors bors bot deleted the to_indented_str branch October 22, 2022 20:14
@Razican Razican added the hacktoberfest-accepted PR accepted for Hacktoberfest label Oct 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request hacktoberfest-accepted PR accepted for Hacktoberfest Internal Category for changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants