Skip to content

Conversation

@starkwang
Copy link
Contributor

@starkwangstarkwang commented Jul 8, 2019

This change refactor the previous triple-nested loop and make it more readable by using iterators.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines

This change refactor the previous triple-nested loop and make it more readable by using iterators.
@nodejs-github-botnodejs-github-bot added the http Issues or PRs related to the http subsystem. label Jul 8, 2019
@Trott
Copy link
Member

Trott commented Jul 9, 2019

I'm guessing this probably doesn't need a benchmark but mentioning it in case I'm wrong about that.

@Trott
Copy link
Member

Trott commented Jul 9, 2019

@nodejs/http

@Trott
Copy link
Member

Trott commented Jul 9, 2019

I'm guessing this probably doesn't need a benchmark but mentioning it in case I'm wrong about that.

@mscdex ^^^^^

@starkwang
Copy link
ContributorAuthor

1 similar comment
@nodejs-github-bot
Copy link
Collaborator

};

functiondestroySockets(sockets){
for(constsetKeyinsockets){
Copy link

Choose a reason for hiding this comment

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

briefer:

Suggested change
for(constsetKeyinsockets){
for(constsocketofObject.values(sockets).flat()){

Copy link
Contributor

Choose a reason for hiding this comment

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

But probably also much less performant.

Copy link
Member

Choose a reason for hiding this comment

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

in changes the behavior though. Before, the prototype would not be checked but now it does.

I do not know why flat was suggested. It should already be a flat array?

I think in this specific case it should be fine to use Object.values, since it should not be a hot path to destroy the sockets.

};

functiondestroySockets(sockets){
for(constsetKeyinsockets){
Copy link
Member

Choose a reason for hiding this comment

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

in changes the behavior though. Before, the prototype would not be checked but now it does.

I do not know why flat was suggested. It should already be a flat array?

I think in this specific case it should be fine to use Object.values, since it should not be a hot path to destroy the sockets.

@starkwangstarkwangforce-pushed the refactor-http-agent-destory branch from 9430bf2 to 73da794CompareJuly 12, 2019 03:28
@starkwang
Copy link
ContributorAuthor

@BridgeAR Could you take another look? : )

@BridgeAR
Copy link
Member

This seems to be superseded by #30958.
@starkwang thank your for your contribution and sorry that this could not land!

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

httpIssues or PRs related to the http subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants

@starkwang@Trott@nodejs-github-bot@BridgeAR@fhinkel@orgads@SimonSchick@shisama@trivikr@mlvzk