Skip to content

Commit

Permalink
src: move DiagnosticFilename inlines into a -inl.h
Browse files Browse the repository at this point in the history
DiagnosticFilename's constructor default values use inlines from
env-inl.h, causing the many users of node_internals.h to include
env-inl.h, even if they never use DiagnosticFilename.

PR-URL: #27839
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
  • Loading branch information
sam-github authored and targos committed May 28, 2019
1 parent 9d9b32e commit 44846ae
Show file tree
Hide file tree
Showing 15 changed files with 45 additions and 21 deletions.
1 change: 0 additions & 1 deletion src/api/environment.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include "env-inl.h"
#include "node.h"
#include "node_context_data.h"
#include "node_errors.h"
Expand Down
1 change: 0 additions & 1 deletion src/api/utils.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include "env-inl.h"
#include "node.h"
#include "node_internals.h"
#include "util-inl.h"
Expand Down
33 changes: 33 additions & 0 deletions src/diagnosticfilename-inl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#ifndef SRC_DIAGNOSTICFILENAME_INL_H_
#define SRC_DIAGNOSTICFILENAME_INL_H_

#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS

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

namespace node {

inline DiagnosticFilename::DiagnosticFilename(
Environment* env,
const char* prefix,
const char* ext) :
filename_(MakeFilename(env->thread_id(), prefix, ext)) {
}

inline DiagnosticFilename::DiagnosticFilename(
uint64_t thread_id,
const char* prefix,
const char* ext) :
filename_(MakeFilename(thread_id, prefix, ext)) {
}

inline const char* DiagnosticFilename::operator*() const {
return filename_.c_str();
}

} // namespace node

#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS

#endif // SRC_DIAGNOSTICFILENAME_INL_H_
1 change: 1 addition & 0 deletions src/heap_utils.cc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "diagnosticfilename-inl.h"
#include "env-inl.h"
#include "memory_tracker-inl.h"
#include "stream_base-inl.h"
Expand Down
3 changes: 0 additions & 3 deletions src/inspector/tracing_agent.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
#include "main_thread_interface.h"
#include "node_internals.h"
#include "node_v8_platform-inl.h"

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

#include <set>
Expand Down
1 change: 0 additions & 1 deletion src/inspector_io.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include "inspector/main_thread_interface.h"
#include "inspector/node_string.h"
#include "base_object-inl.h"
#include "env-inl.h"
#include "debug_utils.h"
#include "node.h"
#include "node_crypto.h"
Expand Down
1 change: 1 addition & 0 deletions src/inspector_profiler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <sstream>
#include "base_object-inl.h"
#include "debug_utils.h"
#include "diagnosticfilename-inl.h"
#include "memory_tracker-inl.h"
#include "node_file.h"
#include "node_internals.h"
Expand Down
2 changes: 1 addition & 1 deletion src/node_api.cc
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#include <node_buffer.h>
#include "env-inl.h"
#define NAPI_EXPERIMENTAL
#include "js_native_api_v8.h"
#include "node_api.h"
#include "node_binding.h"
#include "node_buffer.h"
#include "node_errors.h"
#include "node_internals.h"
#include "threadpoolwork-inl.h"
Expand Down
1 change: 0 additions & 1 deletion src/node_i18n.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
#if defined(NODE_HAVE_I18N_SUPPORT)

#include "base_object-inl.h"
#include "env-inl.h"
#include "node.h"
#include "node_buffer.h"
#include "node_errors.h"
Expand Down
16 changes: 7 additions & 9 deletions src/node_internals.h
Original file line number Diff line number Diff line change
Expand Up @@ -324,17 +324,15 @@ class DiagnosticFilename {
public:
static void LocalTime(TIME_TYPE* tm_struct);

DiagnosticFilename(Environment* env,
const char* prefix,
const char* ext) :
filename_(MakeFilename(env->thread_id(), prefix, ext)) {}
inline DiagnosticFilename(Environment* env,
const char* prefix,
const char* ext);

DiagnosticFilename(uint64_t thread_id,
const char* prefix,
const char* ext) :
filename_(MakeFilename(thread_id, prefix, ext)) {}
inline DiagnosticFilename(uint64_t thread_id,
const char* prefix,
const char* ext);

const char* operator*() const { return filename_.c_str(); }
inline const char* operator*() const;

private:
static std::string MakeFilename(
Expand Down
1 change: 1 addition & 0 deletions src/node_report.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "env-inl.h"
#include "node_report.h"
#include "debug_utils.h"
#include "diagnosticfilename-inl.h"
#include "node_internals.h"
#include "node_metadata.h"
#include "util.h"
Expand Down
1 change: 0 additions & 1 deletion src/node_report_utils.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include "env-inl.h"
#include "node_internals.h"
#include "node_report.h"
#include "util-inl.h"
Expand Down
2 changes: 1 addition & 1 deletion src/node_trace_events.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "base_object-inl.h"
#include "env.h"
#include "env-inl.h"
#include "memory_tracker-inl.h"
#include "node.h"
#include "node_internals.h"
Expand Down
1 change: 0 additions & 1 deletion tools/snapshot/node_mksnapshot.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include <string>
#include <vector>

#include "env-inl.h"
#include "libplatform/libplatform.h"
#include "node_internals.h"
#include "snapshot_builder.h"
Expand Down
1 change: 0 additions & 1 deletion tools/snapshot/snapshot_builder.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include "snapshot_builder.h"
#include <iostream>
#include <sstream>
#include "env-inl.h"
#include "node_internals.h"
#include "node_main_instance.h"
#include "node_v8_platform-inl.h"
Expand Down

0 comments on commit 44846ae

Please sign in to comment.