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

http: refactor agent.destroy() #28596

Closed

Conversation

starkwang
Copy link
Contributor

@starkwang starkwang 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-bot nodejs-github-bot added the http Issues or PRs related to the http subsystem. label Jul 8, 2019
lib/_http_agent.js Outdated Show resolved Hide resolved
@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
Contributor Author

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

};

function destroySockets(sockets) {
for (const setKey in sockets) {
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 (const setKey in sockets) {
for (const socket of Object.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.

};

function destroySockets(sockets) {
for (const setKey in sockets) {
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.

@starkwang starkwang force-pushed the refactor-http-agent-destory branch from 9430bf2 to 73da794 Compare July 12, 2019 03:28
@starkwang
Copy link
Contributor Author

@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!

@BridgeAR BridgeAR closed this Jan 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
http Issues or PRs related to the http subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

10 participants