Skip to content

Conversation

@leeseean
Copy link
Contributor

syntax es5 -> es6

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines
Affected core subsystem(s)

syntax es5 -> es6
@nodejs-github-bot nodejs-github-bot added the http Issues or PRs related to the http subsystem. label Nov 13, 2017

function validateHost(host, name) {
if (host != null && typeof host !== 'string') {
if (host !== null && typeof host !== 'string') {
Copy link
Contributor

Choose a reason for hiding this comment

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

Changes like this are not safe because it changes behavior, specifically undefined will no longer be considered in addition to null.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thank you for your suggest!

@mscdex
Copy link
Contributor

mscdex commented Nov 13, 2017

Have you ran the relevant http benchmarks to make sure there are no performance regressions?

Copy link
Contributor

@apapirovski apapirovski left a comment

Choose a reason for hiding this comment

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

Thanks for trying to improve Node @leeseean. I do have some concerns about this as it will make backporting harder going forward. Even if there are no performance differences for let/const for the current version of V8 (which I still think let has some downsides), there are definitely differences for older versions which means we won't be able to backport this PR and any PRs that subsequently change this code will need to be manually backported.

If this does go forward, I think this will need to be cleaned up. I'm seeing a lot of let where const would do.

if (method != null && !methodIsString) {
let method = options.method;
const methodIsString = (typeof method === 'string');
if (method !== null && !methodIsString) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above, flagged by @mscdex.

for (var i = 0; i < keys.length; i++) {
var key = keys[i];
let keys = Object.keys(options.headers);
for (let i = 0; i < keys.length; i++) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This won't pass our lint rules and will be worse for performance.

Copy link
Contributor

Choose a reason for hiding this comment

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

Performance-wise V8 was supposed to have fixed this particular use case awhile ago, but you never know if there are weird edge cases or something yet. That is the main reason for my comment about checking for performance regressions just to be sure.

Copy link
Contributor

Choose a reason for hiding this comment

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

I believe that @bmeurer flagged this as still being potentially problematic (in some limited scenarios) in an earlier PR that tried to get rid of the lint rule. Either way, this wouldn't pass the CI (linter) so it will need to be changed.

assert(parser && parser.socket === socket);

var ret = parser.execute(d);
let ret = parser.execute(d);
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 not sure I see where this is changing. const?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thank you for your suggest!

var port = options.port = options.port || defaultPort || 80;
var host = options.host = validateHost(options.hostname, 'hostname') ||
let port = options.port = options.port || defaultPort || 80;
let host = options.host = validateHost(options.hostname, 'hostname') ||
Copy link
Contributor

Choose a reason for hiding this comment

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

Do either of these change? const?

@mscdex
Copy link
Contributor

mscdex commented Nov 14, 2017

Closing this for #17011.

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.

5 participants