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

cleanup: reduce the number of `#include "env.h"` and `#include "env-inl.h"` in the code base #27531

Open
joyeecheung opened this issue May 2, 2019 · 3 comments

Comments

Projects
None yet
3 participants
@joyeecheung
Copy link
Member

commented May 2, 2019

Because of how Environment is used in the code base (e.g. to grab Node.js things from callbacks, to have fast access to persistent properties), Environment is used in almost every C++ file, which results in a lot of #include "env.h" and #include "env-inl.h" in the code base. However many files (mostly headers) only need a forward declaration of class Environment instead of requiring env.h or env-inl.h because they just need to know the Environment type to have Environment* in the declarations. When there is code in a header that actually uses something from Environment (so a forward declaration is not enough), the code may be moved out of the header if it is not in a hot path (i.e. it does not need to be inlined).

Reducing the number of these includes should reduce the amount of files being compiled whenever env.h/env-inl.h is touched.

@joyeecheung

This comment has been minimized.

Copy link
Member Author

commented May 2, 2019

I think this is a good first issue if you know how forward declaration and C++ headers work. If nobody picks this up (say in a week) I'll do it anyway because...I touch env.h too much these days and want to spend less time waiting for recompilation ;)

@refack

This comment has been minimized.

Copy link
Member

commented May 2, 2019

if it is not in a hot path (i.e. it does not need to be inlined).

BTW I believe that as of C++11 this assumption is not as relevant as it used to be.
Language-wise inline has come to mean "may have multiple definitions" on the one hand, and compilers are now inlining anything and do LTO if they think it will improve performance, on the other hand.

@Jinshuo1994

This comment has been minimized.

Copy link

commented May 4, 2019

I think the instructions from @joyeecheung are very clear. Can I take up this issue? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.