-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
src: cleanup unused headers #30328
src: cleanup unused headers #30328
Conversation
src/connect_wrap.cc
Outdated
namespace v8 { | ||
class Object; | ||
template <class T> class Local; | ||
} // namespace v8 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file includes v8.h indirectly anyway, should we add this here? (ditto below?)
Like, any file that actively uses V8 APIs will have it included anyway, through node.h
or otherwise…
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll take a look, remove the declarations and let you know of the result (sometime tomorrow afternoon / evening)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I've removed the declarations you pointed, and they were as you said not needed.
Were the ones removed by my last commit all the ones you were referring to?
Isn't it possible to utilize some kind of tooling to automatically check/take care of this sort of thing? |
@mscdex This PR originates from testing one of such tools (include-what-you-use) against node's c++ codebase. The problem I've noticed with include-what-you-use is that it works on the assumption that everything used in a file, is going to be explicitly included. This assumption seems not to be aligned with the reality of node's C++ code, where, as @addaleax pointed in her review comment, some declarations are fine to be implicitly included by includes of your includes. As for other tools, I've never used C++ professionally / in large codebases and I don't know if they exists, as I'm way outside C++ 's ecosystem. |
src/connect_wrap.h
Outdated
|
||
namespace node { | ||
|
||
class Environment; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
async_wrap.h
is guaranteed to have a forward declaration of this because it uses it for the AsyncWrap
constructor
src/connection_wrap.h
Outdated
namespace v8 { | ||
class Object; | ||
template <class T> class Local; | ||
} // namespace v8 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stream_wrap.h
is guaranteed to include v8.h
because it defines a BaseObject
subclass
#include "base_object-inl.h" | ||
|
||
namespace node { | ||
|
||
class Environment; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
base_object-inl.h
is guaranteed to have a forward declaration of this because it uses it as a return type… however, it’s not great that base_object-inl.h
is included here rather than base_object.h
. Can we replace it with the latter?
@@ -27,7 +27,7 @@ | |||
// Decodes a v8::Local<v8::String> or Buffer to a raw char* | |||
|
|||
#include "v8.h" | |||
#include "env.h" | |||
#include "env-inl.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain why this is necessary? If an inline function here uses an inline function from env.h
, then it’s probably best to either make it non-inline and move it to the .cc file, or create a string_bytes-inl.h
that defines that function and includes env-inl.h
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The more I think of it, it's probably not necessary and an over reaction on my side to this CI error on osx https://ci.nodejs.org/job/node-test-commit-osx/29819/nodes=osx1011/console
Why would only that build fail for that particular reason still leaves me puzzled
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah… I don’t know either, but I think it makes sense to move StringBytes::InlineDecoder::Decode()
into a string_bytes-inl.h
?
src/udp_wrap.h
Outdated
#include "handle_wrap.h" | ||
#include "uv.h" | ||
#include "v8.h" | ||
|
||
namespace node { | ||
|
||
class AsyncWrap; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
handle_wrap.h
is guaranteed to provide AsyncWrap
because including it defines a subclass of AsyncWrap
@alferpal Looks like there’s a merge commit in here now … can you rebase that out? Our CI doesn’t handle merge commits well, unfortunately |
Ah, didn't realise. Sorry, will fix it in a couple hours.
…On Thu, 28 Nov 2019, 00:57 Anna Henningsen, ***@***.***> wrote:
@alferpal <https://github.com/alferpal> Looks like there’s a merge commit
in here now … can you rebase that out? Our CI doesn’t handle merge commits
well, unfortunately
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#30328?email_source=notifications&email_token=AAGDDYRWEAUOBBLIYP45IFTQV4CPRA5CNFSM4JKMQAJ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEFLBMAQ#issuecomment-559289858>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAGDDYSTKHS7AXBBYI2K3DLQV4CPRANCNFSM4JKMQAJQ>
.
|
Node codebase has evolved a lot in the more than 10 years of its existence. As more features (and code) have been added, changed, removed, it's sometimes hard to keep track of what gets used and what not. This commits attempts to clean some of those potentially left-over headers using suggestions from include-what-you-use Refs: #27531
Introduced in a previous commit, this delcarations proved to be not needed.
It seems that the dependency string_bytes had in Environment::isolate() was always supplied transitively and not directly. Removing env-inl from api/encoding.cc broke this dependency chain, and this commit attempts to fix this at the root.
Include the plain header file instead of its inline counterpart
Node codebase has evolved a lot in the more than 10 years of its existence. As more features (and code) have been added, changed, removed, it's sometimes hard to keep track of what gets used and what not. This commits attempts to clean some of those potentially left-over headers using suggestions from include-what-you-use Refs: #27531 PR-URL: #30328 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Landed in 7686b5a, sorry for all the delays and thanks for the PR! 🎉 |
Node codebase has evolved a lot in the more than 10 years of its existence. As more features (and code) have been added, changed, removed, it's sometimes hard to keep track of what gets used and what not. This commits attempts to clean some of those potentially left-over headers using suggestions from include-what-you-use Refs: #27531 PR-URL: #30328 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Node codebase has evolved a lot in the more than 10 years of its existence. As more features (and code) have been added, changed, removed, it's sometimes hard to keep track of what gets used and what not. This commits attempts to clean some of those potentially left-over headers using suggestions from include-what-you-use Refs: #27531 PR-URL: #30328 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Node codebase has evolved a lot in the more than 10 years of its existence. As more features (and code) have been added, changed, removed, it's sometimes hard to keep track of what gets used and what not. This commits attempts to clean some of those potentially left-over headers using suggestions from include-what-you-use Refs: #27531 PR-URL: #30328 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Node codebase has evolved a lot in the more than 10 years of its
existence. As more features (and code) have been added, changed,
removed, it's sometimes hard to keep track of what gets used and what
not.
This commits attempts to clean some of those potentially left-over
headers using suggestions from include-what-you-use
Refs: #27531
make -j4 test
(UNIX)In addition, also tested with
make -j8
make -j8 test-all