C++-side refactor by addaleax · Pull Request #126 · nodejs/quic
added 10 commits
September 21, 2019 00:49Using `std::function` and an opaque pointer are pretty much antithetical. This commit chooses the more C++-y variant, i.e. `std::function`.
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.
- 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.
addaleax added a commit that referenced this pull request
Sep 23, 2019Using `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, 2019Using `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, 2019Prefer 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, 2019Move 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, 2019Use 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, 2019Use 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, 2019The 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, 2019This 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, 2019Use 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, 2019The 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, 2019The 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, 2019The 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters