Skip to content

Conversation

@alxhub
Copy link
Member

@alxhub alxhub commented Jun 18, 2018

  • Support inputs and outputs from metadata.
  • Remove option to use default value parameter for inject() in code generation.

inject() was changed in da31db7 to not take a default value parameter,
so injectable_compiler_2 should not request the use of one when
using inject().
@mary-poppins
Copy link

Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be a standard for loop or doesn't matter?

Copy link
Member Author

Choose a reason for hiding this comment

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

It could be. I've been taking an approach where I use ES6/fluent code unless something is provably a performance bottleneck.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm with @alfaproject on this, may as well write a for loop. One less function allocation per call to this function.

Copy link
Member Author

Choose a reason for hiding this comment

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

I find the fluent form much more readable, and it's used throughout the compiler today. I would rather not optimize prematurely. If benchmarks show that these temporary allocations (which are short lived anyway) cause significant performance issues, then we should optimize it. Until then, my goal is to keep the code as readable as possible.

Copy link
Contributor

Choose a reason for hiding this comment

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

I meant:

for (const value of values) {
  const [field, property] = value.split(',').map(piece => piece.trim());
  map[field] = property || field;
}

which is just as readable (I think) with the benefit of being more performant.

@alxhub alxhub requested a review from benlesh June 18, 2018 21:05
Copy link
Contributor

@benlesh benlesh left a comment

Choose a reason for hiding this comment

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

A few small things, overall looks good.

Copy link
Contributor

Choose a reason for hiding this comment

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

You might considier making this into a pure function that reduces into the map. It can be used to create the map above.

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

remove the map() here, and do the trim() on the next line where you need to. One less Array allocation.

Copy link
Member Author

Choose a reason for hiding this comment

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

As we discussed, I'm not worried about optimizing the allocations at the moment.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm with @alfaproject on this, may as well write a for loop. One less function allocation per call to this function.

Copy link
Contributor

Choose a reason for hiding this comment

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

I know you didn't touch this, but is the omission of a hasOwnProperty check here intentional?

Copy link
Contributor

Choose a reason for hiding this comment

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

And as below, this could be a for..of loop, that will save a function allocation per turn through this loop.

Copy link
Contributor

Choose a reason for hiding this comment

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

The same questions/problems exist in other code below (that you didn't touch) in extractHostBindings

Copy link
Member Author

Choose a reason for hiding this comment

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

I know you didn't touch this, but is the omission of a hasOwnProperty check here intentional.

Can you elaborate on what the hasOwnProperty check would check? I don't follow.

@alxhub alxhub dismissed benlesh’s stale review June 20, 2018 16:45

Most comments addressed, please re-review.

@mary-poppins
Copy link

@alxhub alxhub added action: merge The PR is ready for merge by the caretaker target: major This PR is targeted for the next major release labels Jun 21, 2018
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 13, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker cla: yes target: major This PR is targeted for the next major release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants