C++-side refactor by addaleax · Pull Request #126 · nodejs/quic

added 10 commits

September 21, 2019 00:49
Using `std::function` and an opaque pointer are pretty much
antithetical. This commit chooses the more C++-y variant, i.e.
`std::function`.
Using `typedef enum` is a C-ism.
Prefer inline functions over macros, use explicit nullptr checks,
do not mark functions with implicit inline linkage as inline,
re-use code where possible, etc.
Move methods that do not need to be inline into their own file,
replace `std::function` with a template variant for performance,
remove `inline` for functions with implicit inline linkage.
Use the more C++-y `std::function` approach which renders opaque
pointers unnecessary.
- Do not create new `v8::Function` objects, both for performance
  and because it is unclear whether that leaks memory
  (Node.js issue 28988).
- Do not put functions into the inline header that do not need to
  be there or that do not make sense as inline functions
  (in particular, callbacks that are provided to C libraries can
  not be realized as inline functions by the compiler).
- Remove implicit/redundant `inline` qualifiers and add appropriate
  `const` qualifiers.
- Remove unnecessary `this->` prefixes.
- Return early for JS failures rather than accumulating them.
- Minor stylistic changes.
Use a template class instead of virtual methods to allow inlining
the subclass methods, as well as other minor cleanups.
The extensive testing done on http2 makes it easier to make sure
the implementation is correct (and doesn’t diverge unnecessarily).
This listener currently had the drawbacks of leaking memory
when an error is encountered and was otherwise equivalent to
the default listener.
Use default initializers, `const` qualifiers, minor style changes
to match more common style in the codebase.

@addaleax

@addaleax

addaleax added a commit that referenced this pull request

Sep 23, 2019
Using `std::function` and an opaque pointer are pretty much
antithetical. This commit chooses the more C++-y variant, i.e.
`std::function`.

PR-URL: #126
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>

addaleax added a commit that referenced this pull request

Sep 23, 2019
Using `typedef enum` is a C-ism.

PR-URL: #126
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>

addaleax added a commit that referenced this pull request

Sep 23, 2019
Prefer inline functions over macros, use explicit nullptr checks,
do not mark functions with implicit inline linkage as inline,
re-use code where possible, etc.

PR-URL: #126
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>

addaleax added a commit that referenced this pull request

Sep 23, 2019
Move methods that do not need to be inline into their own file,
replace `std::function` with a template variant for performance,
remove `inline` for functions with implicit inline linkage.

PR-URL: #126
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>

addaleax added a commit that referenced this pull request

Sep 23, 2019
Use the more C++-y `std::function` approach which renders opaque
pointers unnecessary.

PR-URL: #126
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>

addaleax added a commit that referenced this pull request

Sep 23, 2019
- Do not create new `v8::Function` objects, both for performance
  and because it is unclear whether that leaks memory
  (Node.js issue 28988).
- Do not put functions into the inline header that do not need to
  be there or that do not make sense as inline functions
  (in particular, callbacks that are provided to C libraries can
  not be realized as inline functions by the compiler).
- Remove implicit/redundant `inline` qualifiers and add appropriate
  `const` qualifiers.
- Remove unnecessary `this->` prefixes.
- Return early for JS failures rather than accumulating them.
- Minor stylistic changes.

PR-URL: #126
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>

addaleax added a commit that referenced this pull request

Sep 23, 2019
Use a template class instead of virtual methods to allow inlining
the subclass methods, as well as other minor cleanups.

PR-URL: #126
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>

addaleax added a commit that referenced this pull request

Sep 23, 2019
The extensive testing done on http2 makes it easier to make sure
the implementation is correct (and doesn’t diverge unnecessarily).

PR-URL: #126
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>

addaleax added a commit that referenced this pull request

Sep 23, 2019
This listener currently had the drawbacks of leaking memory
when an error is encountered and was otherwise equivalent to
the default listener.

PR-URL: #126
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>

addaleax added a commit that referenced this pull request

Sep 23, 2019
Use default initializers, `const` qualifiers, minor style changes
to match more common style in the codebase.

PR-URL: #126
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>

jasnell pushed a commit that referenced this pull request

Oct 2, 2019
The extensive testing done on http2 makes it easier to make sure
the implementation is correct (and doesn’t diverge unnecessarily).

PR-URL: #126
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>

jasnell pushed a commit that referenced this pull request

Oct 3, 2019
The extensive testing done on http2 makes it easier to make sure
the implementation is correct (and doesn’t diverge unnecessarily).

PR-URL: #126
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>

jasnell pushed a commit that referenced this pull request

Oct 3, 2019
The extensive testing done on http2 makes it easier to make sure
the implementation is correct (and doesn’t diverge unnecessarily).

PR-URL: #126
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>

addaleax added a commit to nodejs/node that referenced this pull request

Dec 7, 2019

addaleax added a commit to nodejs/node that referenced this pull request

Dec 7, 2019

addaleax added a commit to nodejs/node that referenced this pull request

Dec 7, 2019

addaleax added a commit to nodejs/node that referenced this pull request

Dec 7, 2019

addaleax added a commit to nodejs/node that referenced this pull request

Dec 7, 2019

targos pushed a commit to nodejs/node that referenced this pull request

Dec 9, 2019

targos pushed a commit to nodejs/node that referenced this pull request

Dec 9, 2019

targos pushed a commit to nodejs/node that referenced this pull request

Dec 9, 2019

targos pushed a commit to nodejs/node that referenced this pull request

Dec 9, 2019

targos pushed a commit to nodejs/node that referenced this pull request

Dec 9, 2019

targos pushed a commit to nodejs/node that referenced this pull request

Jan 14, 2020

targos pushed a commit to nodejs/node that referenced this pull request

Jan 14, 2020

targos pushed a commit to nodejs/node that referenced this pull request

Jan 14, 2020

targos pushed a commit to nodejs/node that referenced this pull request

Jan 14, 2020

targos pushed a commit to nodejs/node that referenced this pull request

Jan 14, 2020

BethGriggs pushed a commit to nodejs/node that referenced this pull request

Feb 6, 2020

BethGriggs pushed a commit to nodejs/node that referenced this pull request

Feb 6, 2020

BethGriggs pushed a commit to nodejs/node that referenced this pull request

Feb 6, 2020

BethGriggs pushed a commit to nodejs/node that referenced this pull request

Feb 6, 2020

BethGriggs pushed a commit to nodejs/node that referenced this pull request

Feb 6, 2020