diff options
author | Joyee Cheung <joyeec9h3@gmail.com> | 2018-12-19 00:23:47 +0300 |
---|---|---|
committer | Joyee Cheung <joyeec9h3@gmail.com> | 2018-12-21 02:46:47 +0300 |
commit | 263d13766f08fb3444c205ce7ecaaa3efd89546a (patch) | |
tree | 05e0c1c66b4619090da44dbc08a7135f300ec1ac /src/node_metadata.h | |
parent | a29c93a1472947ed053b674cfd670a9d191594ea (diff) |
src: initialize ICU version in per_process::metadata.versions
Instead of
- Initialize the ICU versions in JS land after consulting
internalBinding('config').hasIntl
- Joining the version keys in C++
- Splitting the keys in JS and call into C++ again to get the value for
each of the keys
Do:
- Guard the initialization code behind `NODE_HAVE_I18N_SUPPORT`
- Do the initialization in C++ right after ICU data is loaded
- Initialize each version directly using ICU functions/constants,
and put them in per_process::metadata.versions. These will be
copied into `process.versions` naturally later.
This way, the initialization of the versions won't be called
in worker threads again.
PR-URL: https://github.com/nodejs/node/pull/25115
Reviewed-By: Steven R Loomis <srloomis@us.ibm.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src/node_metadata.h')
-rw-r--r-- | src/node_metadata.h | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/src/node_metadata.h b/src/node_metadata.h index 99ccc23cb27..3c3a430dd73 100644 --- a/src/node_metadata.h +++ b/src/node_metadata.h @@ -25,14 +25,38 @@ namespace node { #define NODE_VERSIONS_KEY_CRYPTO(V) #endif +#ifdef NODE_HAVE_I18N_SUPPORT +#define NODE_VERSIONS_KEY_INTL(V) \ + V(cldr) \ + V(icu) \ + V(tz) \ + V(unicode) +#else +#define NODE_VERSIONS_KEY_INTL(V) +#endif // NODE_HAVE_I18N_SUPPORT + #define NODE_VERSIONS_KEYS(V) \ NODE_VERSIONS_KEYS_BASE(V) \ - NODE_VERSIONS_KEY_CRYPTO(V) + NODE_VERSIONS_KEY_CRYPTO(V) \ + NODE_VERSIONS_KEY_INTL(V) class Metadata { public: + Metadata() = default; + Metadata(Metadata&) = delete; + Metadata(Metadata&&) = delete; + Metadata operator=(Metadata&) = delete; + Metadata operator=(Metadata&&) = delete; + struct Versions { Versions(); + +#ifdef NODE_HAVE_I18N_SUPPORT + // Must be called on the main thread after + // i18n::InitializeICUDirectory() + void InitializeIntlVersions(); +#endif // NODE_HAVE_I18N_SUPPORT + #define V(key) std::string key; NODE_VERSIONS_KEYS(V) #undef V |