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

http2: general code cleanups #19400

Closed
wants to merge 4 commits into from
Closed

Conversation

jasnell
Copy link
Member

@jasnell jasnell commented Mar 16, 2018

/cc @addaleax @mcollina

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines

Most of the inlines were leftovers from a much older design
iteration and are largely pointless or counter productive.
Use of a MaybeStackBuffer was just silly. Fix a long standing todo
Reduce code duplication a bit.
@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs related to general changes in the lib or src directory. labels Mar 16, 2018
};
session->MakeCallback(env->error_string(), arraysize(argv), argv);
Local<Value> argv = Integer::New(isolate, lib_error_code);
session->MakeCallback(env->error_string(), 1, &argv);
Copy link
Member

Choose a reason for hiding this comment

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

You may want to call this arg, since it’s not really a vector any longer :)

(ditto below)

@jasnell
Copy link
Member Author

jasnell commented Mar 16, 2018

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -283,13 +251,13 @@ Http2Session::Http2Settings::~Http2Settings() {
// Generates a Buffer that contains the serialized payload of a SETTINGS
// frame. This can be used, for instance, to create the Base64-encoded
// content of an Http2-Settings header field.
inline Local<Value> Http2Session::Http2Settings::Pack() {
Local<Value> Http2Session::Http2Settings::Pack() {
Copy link
Member

Choose a reason for hiding this comment

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

is it ok to remove this inline directive here and in the other functions? Wouldn't this impact perf somehow?

Copy link
Member

@addaleax addaleax Mar 17, 2018

Choose a reason for hiding this comment

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

@mcollina It’s not only okay, it’s more or less the correct thing to do.

This has a pretty good explanation. tl;dr: Compilers are generally better than humans at judging what functions to inline or not, and will gladly ignore this advice. However, inline does affect the linkage properties of a function, and so its primary use should be to mark functions that are defined in header files (outside of a class definition).

I just tested it with gcc, and the compiler output is the same before and after this commit, byte-for-byte.

jasnell added a commit that referenced this pull request Mar 18, 2018
Most of the inlines were leftovers from a much older design
iteration and are largely pointless or counter productive.

PR-URL: #19400
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
jasnell added a commit that referenced this pull request Mar 18, 2018
Use of a MaybeStackBuffer was just silly. Fix a long standing todo
Reduce code duplication a bit.

PR-URL: #19400
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
jasnell added a commit that referenced this pull request Mar 18, 2018
PR-URL: #19400
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
@jasnell
Copy link
Member Author

jasnell commented Mar 18, 2018

Landed in 49799f3, 224941b, and d74184c

@jasnell jasnell closed this Mar 18, 2018
MylesBorins pushed a commit that referenced this pull request Mar 20, 2018
Most of the inlines were leftovers from a much older design
iteration and are largely pointless or counter productive.

PR-URL: #19400
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
MylesBorins pushed a commit that referenced this pull request Mar 20, 2018
Use of a MaybeStackBuffer was just silly. Fix a long standing todo
Reduce code duplication a bit.

PR-URL: #19400
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
MylesBorins pushed a commit that referenced this pull request Mar 20, 2018
PR-URL: #19400
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
MylesBorins pushed a commit that referenced this pull request Mar 20, 2018
Most of the inlines were leftovers from a much older design
iteration and are largely pointless or counter productive.

PR-URL: #19400
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
MylesBorins pushed a commit that referenced this pull request Mar 20, 2018
Use of a MaybeStackBuffer was just silly. Fix a long standing todo
Reduce code duplication a bit.

PR-URL: #19400
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
MylesBorins pushed a commit that referenced this pull request Mar 20, 2018
PR-URL: #19400
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
@targos targos mentioned this pull request Mar 20, 2018
@codebytere
Copy link
Member

codebytere commented Oct 18, 2018

@jasnell could you backport this to v8.x when you have a chance (or mark don't-land otherwise)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs related to general changes in the lib or src directory.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants