From 290315ace7eed6eeeb300754dd68fc1af4d80c9b Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Tue, 8 Aug 2017 19:56:02 +0200 Subject: [PATCH] src: refactor `#include` handling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `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: https://github.com/nodejs/node/pull/14697 Reviewed-By: Tobias Nießen Reviewed-By: Refael Ackermann Reviewed-By: James M Snell --- src/async-wrap-inl.h | 5 ----- src/backtrace_posix.cc | 2 +- src/env-inl.h | 1 + src/env.cc | 4 +--- src/env.h | 4 ++++ src/inspector_agent.cc | 5 +---- src/node.cc | 1 - src/node.h | 4 ---- src/node_api.cc | 2 -- src/node_buffer.h | 3 +-- src/node_constants.cc | 4 +--- src/node_contextify.cc | 5 ----- src/node_counters.h | 2 +- src/node_dtrace.cc | 5 +---- src/node_dtrace.h | 4 +--- src/node_file.cc | 4 ---- src/node_i18n.h | 2 +- src/node_internals.h | 2 ++ src/node_javascript.h | 3 +-- src/node_main.cc | 2 ++ src/node_os.cc | 5 +---- src/node_perf.cc | 6 +----- src/node_url.cc | 6 ------ src/node_util.cc | 5 +---- src/node_watchdog.cc | 2 -- src/string_search.h | 2 +- src/tls_wrap.cc | 2 -- src/util.cc | 1 - test/cctest/node_test_fixture.h | 1 + test/cctest/test_environment.cc | 4 +--- 30 files changed, 25 insertions(+), 73 deletions(-) diff --git a/src/async-wrap-inl.h b/src/async-wrap-inl.h index 4f8b7c3f8dd914..ed5a0c0d279048 100644 --- a/src/async-wrap-inl.h +++ b/src/async-wrap-inl.h @@ -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 { diff --git a/src/backtrace_posix.cc b/src/backtrace_posix.cc index 8fd798757a544a..0c69d820e7212a 100644 --- a/src/backtrace_posix.cc +++ b/src/backtrace_posix.cc @@ -1,4 +1,4 @@ -#include "node.h" +#include "node_internals.h" #if defined(__linux__) #include diff --git a/src/env-inl.h b/src/env-inl.h index 404c06c6f453bd..ddfb5fd93ffcf3 100644 --- a/src/env-inl.h +++ b/src/env-inl.h @@ -31,6 +31,7 @@ #include "util-inl.h" #include "uv.h" #include "v8.h" +#include "node_perf_common.h" #include #include diff --git a/src/env.cc b/src/env.cc index 076198cd626a81..ba5caa1ec3acca 100644 --- a/src/env.cc +++ b/src/env.cc @@ -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) diff --git a/src/env.h b/src/env.h index 13b1f4cb137bce..4af87192df8128 100644 --- a/src/env.h +++ b/src/env.h @@ -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, diff --git a/src/inspector_agent.cc b/src/inspector_agent.cc index 828006ecf2fbb4..9f33b3d31e69e6 100644 --- a/src/inspector_agent.cc +++ b/src/inspector_agent.cc @@ -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" diff --git a/src/node.cc b/src/node.cc index 664ae22a9ae258..30cbb11efa9e25 100644 --- a/src/node.cc +++ b/src/node.cc @@ -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" diff --git a/src/node.h b/src/node.h index fbd17d2ca09c7f..5fe7bde4289ae4 100644 --- a/src/node.h +++ b/src/node.h @@ -169,10 +169,6 @@ NODE_EXTERN v8::Local MakeCallback( } // namespace node -#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS -#include "node_internals.h" -#endif - #include #include diff --git a/src/node_api.cc b/src/node_api.cc index 7bb97c8076fac3..8c55e64b7cda05 100644 --- a/src/node_api.cc +++ b/src/node_api.cc @@ -14,10 +14,8 @@ #include #include #include -#include "uv.h" #include "node_api.h" #include "node_internals.h" -#include "util.h" #define NAPI_VERSION 1 diff --git a/src/node_buffer.h b/src/node_buffer.h index acf9b23c3b3256..d680eb90eb1649 100644 --- a/src/node_buffer.h +++ b/src/node_buffer.h @@ -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 { diff --git a/src/node_constants.cc b/src/node_constants.cc index b8b97b21f9ea39..7fd303dd32fed0 100644 --- a/src/node_constants.cc +++ b/src/node_constants.cc @@ -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 diff --git a/src/node_contextify.cc b/src/node_contextify.cc index b04bd6253e9386..c73db420f18b4e 100644 --- a/src/node_contextify.cc +++ b/src/node_contextify.cc @@ -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 { diff --git a/src/node_counters.h b/src/node_counters.h index 5d866aedb57677..c8a1a88f0b25e0 100644 --- a/src/node_counters.h +++ b/src/node_counters.h @@ -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" diff --git a/src/node_dtrace.cc b/src/node_dtrace.cc index 94d06a7404ed33..4ff2f22d8e835a 100644 --- a/src/node_dtrace.cc +++ b/src/node_dtrace.cc @@ -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 diff --git a/src/node_dtrace.h b/src/node_dtrace.h index c22bf4e7fc0f12..d16e23ddb384b7 100644 --- a/src/node_dtrace.h +++ b/src/node_dtrace.h @@ -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" { /* diff --git a/src/node_file.cc b/src/node_file.cc index cf7f1df5eb98bc..b9b3d34f346e56 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -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 #include diff --git a/src/node_i18n.h b/src/node_i18n.h index adf9feb414df5c..70a0c79f76cf30 100644 --- a/src/node_i18n.h +++ b/src/node_i18n.h @@ -24,7 +24,7 @@ #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS -#include "node.h" +#include "node_internals.h" #include #if defined(NODE_HAVE_I18N_SUPPORT) diff --git a/src/node_internals.h b/src/node_internals.h index 6faf2750d4d039..9b6fae9d6a9cdd 100644 --- a/src/node_internals.h +++ b/src/node_internals.h @@ -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" diff --git a/src/node_javascript.h b/src/node_javascript.h index 3e8528fd211fb6..664778091ff669 100644 --- a/src/node_javascript.h +++ b/src/node_javascript.h @@ -24,8 +24,7 @@ #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS -#include "v8.h" -#include "env.h" +#include "node_internals.h" namespace node { diff --git a/src/node_main.cc b/src/node_main.cc index 7d6d9b1a01bbd4..2a511b92996e86 100644 --- a/src/node_main.cc +++ b/src/node_main.cc @@ -20,8 +20,10 @@ // USE OR OTHER DEALINGS IN THE SOFTWARE. #include "node.h" +#include #ifdef _WIN32 +#include #include #include diff --git a/src/node_os.cc b/src/node_os.cc index c71ca401ed6609..f09cd6fa5a03ff 100644 --- a/src/node_os.cc +++ b/src/node_os.cc @@ -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 diff --git a/src/node_perf.cc b/src/node_perf.cc index 48917d5d4ea971..098cf35220a400 100644 --- a/src/node_perf.cc +++ b/src/node_perf.cc @@ -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 diff --git a/src/node_url.cc b/src/node_url.cc index f8adc7d7af5509..20a869ad7afc63 100644 --- a/src/node_url.cc +++ b/src/node_url.cc @@ -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" diff --git a/src/node_util.cc b/src/node_util.cc index bbbea9ea2254dd..ab1f3c9f91257d 100644 --- a/src/node_util.cc +++ b/src/node_util.cc @@ -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 { diff --git a/src/node_watchdog.cc b/src/node_watchdog.cc index f4020e56f7fb61..af4e9f6fcfe3c2 100644 --- a/src/node_watchdog.cc +++ b/src/node_watchdog.cc @@ -21,8 +21,6 @@ #include "node_watchdog.h" #include "node_internals.h" -#include "util.h" -#include "util-inl.h" #include namespace node { diff --git a/src/string_search.h b/src/string_search.h index dfdb8e9a160460..73e90f5873f767 100644 --- a/src/string_search.h +++ b/src/string_search.h @@ -7,7 +7,7 @@ #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS -#include "node.h" +#include "node_internals.h" #include namespace node { diff --git a/src/tls_wrap.cc b/src/tls_wrap.cc index b5829cf5b82f6c..dce05fabd62160 100644 --- a/src/tls_wrap.cc +++ b/src/tls_wrap.cc @@ -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 { diff --git a/src/util.cc b/src/util.cc index 4a89b3a42f24b0..ef93d16968e465 100644 --- a/src/util.cc +++ b/src/util.cc @@ -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" diff --git a/test/cctest/node_test_fixture.h b/test/cctest/node_test_fixture.h index 79027d25ad8c8d..263f7b96f9daec 100644 --- a/test/cctest/node_test_fixture.h +++ b/test/cctest/node_test_fixture.h @@ -4,6 +4,7 @@ #include #include "gtest/gtest.h" #include "node.h" +#include "node_platform.h" #include "env.h" #include "v8.h" #include "libplatform/libplatform.h" diff --git a/test/cctest/test_environment.cc b/test/cctest/test_environment.cc index 4651e865a99e7d..8beacfa95ece7e 100644 --- a/test/cctest/test_environment.cc +++ b/test/cctest/test_environment.cc @@ -1,6 +1,4 @@ -#include "node.h" -#include "env.h" -#include "v8.h" +#include "node_internals.h" #include "libplatform/libplatform.h" #include