Skip to content

Commit

Permalink
src: refactor #include handling
Browse files Browse the repository at this point in the history
`node_internals.h` already includes the most common headers,
so double includes can be avoided in a lot of cases. Also don’t include
`node_internals.h` from `node.h` implicitly anymore, as that is mostly
unnecessary.

PR-URL: nodejs#14697
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
addaleax committed Sep 14, 2017
1 parent 4ae0afb commit 290315a
Show file tree
Hide file tree
Showing 30 changed files with 25 additions and 73 deletions.
5 changes: 0 additions & 5 deletions src/async-wrap-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,7 @@
#include "async-wrap.h"
#include "base-object.h"
#include "base-object-inl.h"
#include "env.h"
#include "env-inl.h"
#include "node_internals.h"
#include "util.h"
#include "util-inl.h"
#include "v8.h"

namespace node {

Expand Down
2 changes: 1 addition & 1 deletion src/backtrace_posix.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "node.h"
#include "node_internals.h"

#if defined(__linux__)
#include <features.h>
Expand Down
1 change: 1 addition & 0 deletions src/env-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "util-inl.h"
#include "uv.h"
#include "v8.h"
#include "node_perf_common.h"

#include <stddef.h>
#include <stdint.h>
Expand Down
4 changes: 1 addition & 3 deletions src/env.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#include "env.h"
#include "env-inl.h"
#include "node_internals.h"
#include "async-wrap.h"
#include "v8.h"
#include "v8-profiler.h"

#if defined(_MSC_VER)
Expand Down
4 changes: 4 additions & 0 deletions src/env.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ struct nghttp2_rcbuf;

namespace node {

namespace performance {
struct performance_state;
}

// Pick an index that's hopefully out of the way when we're embedded inside
// another application. Performance-wise or memory-wise it doesn't matter:
// Context::SetAlignedPointerInEmbedderData() is backed by a FixedArray,
Expand Down
5 changes: 1 addition & 4 deletions src/inspector_agent.cc
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
#include "inspector_agent.h"

#include "inspector_io.h"
#include "env.h"
#include "env-inl.h"
#include "node.h"
#include "node_internals.h"
#include "v8-inspector.h"
#include "v8-platform.h"
#include "util.h"
#include "zlib.h"

#include "libplatform/libplatform.h"
Expand Down
1 change: 0 additions & 1 deletion src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.

#include "node.h"
#include "node_buffer.h"
#include "node_constants.h"
#include "node_javascript.h"
Expand Down
4 changes: 0 additions & 4 deletions src/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,6 @@ NODE_EXTERN v8::Local<v8::Value> MakeCallback(

} // namespace node

#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
#include "node_internals.h"
#endif

#include <assert.h>
#include <stdint.h>

Expand Down
2 changes: 0 additions & 2 deletions src/node_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@
#include <algorithm>
#include <cmath>
#include <vector>
#include "uv.h"
#include "node_api.h"
#include "node_internals.h"
#include "util.h"

#define NAPI_VERSION 1

Expand Down
3 changes: 1 addition & 2 deletions src/node_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
#ifndef SRC_NODE_BUFFER_H_
#define SRC_NODE_BUFFER_H_

#include "node.h"
#include "v8.h"
#include "node_internals.h"

namespace node {

Expand Down
4 changes: 1 addition & 3 deletions src/node_constants.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@
// USE OR OTHER DEALINGS IN THE SOFTWARE.

#include "node_constants.h"
#include "env.h"
#include "env-inl.h"
#include "node_internals.h"

#include "uv.h"
#include "zlib.h"

#include <errno.h>
Expand Down
5 changes: 0 additions & 5 deletions src/node_contextify.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,10 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.

#include "node.h"
#include "node_internals.h"
#include "node_watchdog.h"
#include "base-object.h"
#include "base-object-inl.h"
#include "env.h"
#include "env-inl.h"
#include "util.h"
#include "util-inl.h"
#include "v8-debug.h"

namespace node {
Expand Down
2 changes: 1 addition & 1 deletion src/node_counters.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS

#include "node.h"
#include "node_internals.h"

#ifdef HAVE_PERFCTR
#include "node_win32_perfctr_provider.h"
Expand Down
5 changes: 1 addition & 4 deletions src/node_dtrace.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,7 @@
#define NODE_GC_DONE(arg0, arg1, arg2)
#endif

#include "env.h"
#include "env-inl.h"

#include "util.h"
#include "node_internals.h"

#include <string.h>

Expand Down
4 changes: 1 addition & 3 deletions src/node_dtrace.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@

#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS

#include "node.h"
#include "v8.h"
#include "env.h"
#include "node_internals.h"

extern "C" {
/*
Expand Down
4 changes: 0 additions & 4 deletions src/node_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,13 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.

#include "node.h"
#include "node_buffer.h"
#include "node_internals.h"
#include "node_stat_watcher.h"

#include "env.h"
#include "env-inl.h"
#include "req-wrap.h"
#include "req-wrap-inl.h"
#include "string_bytes.h"
#include "util.h"

#include <fcntl.h>
#include <sys/types.h>
Expand Down
2 changes: 1 addition & 1 deletion src/node_i18n.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS

#include "node.h"
#include "node_internals.h"
#include <string>

#if defined(NODE_HAVE_I18N_SUPPORT)
Expand Down
2 changes: 2 additions & 0 deletions src/node_internals.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
#include "node.h"
#include "util.h"
#include "util-inl.h"
#include "env.h"
#include "env-inl.h"
#include "uv.h"
#include "v8.h"
#include "tracing/trace_event.h"
Expand Down
3 changes: 1 addition & 2 deletions src/node_javascript.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@

#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS

#include "v8.h"
#include "env.h"
#include "node_internals.h"

namespace node {

Expand Down
2 changes: 2 additions & 0 deletions src/node_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
// USE OR OTHER DEALINGS IN THE SOFTWARE.

#include "node.h"
#include <stdio.h>

#ifdef _WIN32
#include <windows.h>
#include <VersionHelpers.h>
#include <WinError.h>

Expand Down
5 changes: 1 addition & 4 deletions src/node_os.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.

#include "node.h"
#include "v8.h"
#include "env.h"
#include "env-inl.h"
#include "node_internals.h"
#include "string_bytes.h"

#include <errno.h>
Expand Down
6 changes: 1 addition & 5 deletions src/node_perf.cc
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
#include "node.h"
#include "v8.h"
#include "env.h"
#include "env-inl.h"
#include "node_internals.h"
#include "node_perf.h"
#include "uv.h"

#include <vector>

Expand Down
6 changes: 0 additions & 6 deletions src/node_url.cc
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
#include "node_url.h"
#include "node.h"
#include "node_internals.h"
#include "env.h"
#include "env-inl.h"
#include "util.h"
#include "util-inl.h"
#include "v8.h"
#include "base-object.h"
#include "base-object-inl.h"
#include "node_i18n.h"
Expand Down
5 changes: 1 addition & 4 deletions src/node_util.cc
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#include "node.h"
#include "node_internals.h"
#include "node_watchdog.h"
#include "v8.h"
#include "env.h"
#include "env-inl.h"

namespace node {
namespace util {
Expand Down
2 changes: 0 additions & 2 deletions src/node_watchdog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@

#include "node_watchdog.h"
#include "node_internals.h"
#include "util.h"
#include "util-inl.h"
#include <algorithm>

namespace node {
Expand Down
2 changes: 1 addition & 1 deletion src/string_search.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS

#include "node.h"
#include "node_internals.h"
#include <string.h>

namespace node {
Expand Down
2 changes: 0 additions & 2 deletions src/tls_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@
#include "node_internals.h"
#include "stream_base.h"
#include "stream_base-inl.h"
#include "util.h"
#include "util-inl.h"

namespace node {

Expand Down
1 change: 0 additions & 1 deletion src/util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.

#include "util.h"
#include "string_bytes.h"
#include "node_buffer.h"
#include "node_internals.h"
Expand Down
1 change: 1 addition & 0 deletions test/cctest/node_test_fixture.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <stdlib.h>
#include "gtest/gtest.h"
#include "node.h"
#include "node_platform.h"
#include "env.h"
#include "v8.h"
#include "libplatform/libplatform.h"
Expand Down
4 changes: 1 addition & 3 deletions test/cctest/test_environment.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#include "node.h"
#include "env.h"
#include "v8.h"
#include "node_internals.h"
#include "libplatform/libplatform.h"

#include <string>
Expand Down

0 comments on commit 290315a

Please sign in to comment.