Skip to content

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

Description

@joyeecheung

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.

Activity

  1. added
    c++Issues and PRs that require attention from people who are familiar with C++.
    good first issueIssues that are suitable for first-time contributors.
    on May 2, 2019
  2. joyeecheung commented on May 2, 2019

    @joyeecheung
    MemberAuthor

    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 ;)

  3. refack commented on May 2, 2019

    @refack
    Contributor

    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.

  4. Jinshuo1994 commented on May 4, 2019

    @Jinshuo1994

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

  5. joyeecheung commented on May 5, 2019

    @joyeecheung
    MemberAuthor

    @Jinshuo1994 sure, go head!

  6. BeniCheni commented on May 9, 2019

    @BeniCheni
    Contributor

    Since I'm learning c++ in context of Node core, I tried out #27620 for this "good first issue" for c++ in core. Thanks.

  7. sarkararpan710 commented on May 18, 2019

    @sarkararpan710

    Hi, This is my first time with contributing to open source and would like to know, how exactly I can help.
    Is this issue still open? Any build instructions that might help me understand how I can contribute.
    Thanks.

  8. joyeecheung commented on May 20, 2019

    @joyeecheung
    MemberAuthor

    @sarkararpan710 There was #27620 but it did not exactly do what this issue requests. Since there has been no progress there since more than a week, I think you can take another stab at this - please take a look at #27620 (comment) about what the request is.

  9. BeniCheni commented on May 20, 2019

    @BeniCheni
    Contributor

    @joyeecheung, sorry about the delay to update the PR. Been busy w. work lately. I’ll close the PR, and look out for other opportunities to do PRs.

  10. carolinedarling commented on May 22, 2019

    @carolinedarling

    @joyeecheung I was wondering if I could work on this issue, is it still something that needs to be worked on? I am brand new to open-source and this would be my first contribution, so please excuse if I ask something ignorant.

  11. sam-github commented on May 22, 2019

    @sam-github
    Contributor

    I suggest waiting until #27755 lands. It probably (mostly) cleans up many unnecessary includes of env-inl.h, but it doesn't deal with the problem of files that include env.h purely for its class declaration.

    As a heads up, to do this, you'll need to know how a class Environment; forward-declaration can be used to replace some instance of #include "env.h".

  12. carolinedarling commented on May 22, 2019

    @carolinedarling

    @sam-github Thank you very much. Will this take about 48 hours? How will I know when it lands? I appreciate your comment.

  13. sam-github commented on May 22, 2019

    @sam-github
    Contributor

    Hopefully will land by the end of day. You can probably use the 'subscribe' button on the PR to start getting updates on it.

  14. carolinedarling commented on May 22, 2019

    @carolinedarling

    @sam-github Are we waiting for someone with write access to merge it with Master, am I understanding? Then, I re-build and start working? Thank you. Thank you for your patience with a new person, I am in my last quarter of a CS degree and new to git.

  15. 13 remaining items

  16. added a commit that references this issue on Dec 1, 2019
  17. added a commit that references this issue on Dec 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    c++Issues and PRs that require attention from people who are familiar with C++.good first issueIssues that are suitable for first-time contributors.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      Sponsor
      SponsoredKunjungi sekarang
      Promo