From 6e117504790fe676de8b140643fc85b612d21632 Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Sat, 12 Sep 2020 17:35:21 -0700 Subject: [PATCH] Make the global feature set an instance variable Allow it to be inlined. --- src/future_feature_flags.cpp | 8 +++----- src/future_feature_flags.h | 9 +++++++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/future_feature_flags.cpp b/src/future_feature_flags.cpp index b50ea03e3..a2305bbc7 100644 --- a/src/future_feature_flags.cpp +++ b/src/future_feature_flags.cpp @@ -6,12 +6,10 @@ #include "wcstringutil.h" +features_t::features_t() = default; + /// The set of features applying to this instance. -static features_t global_features; - -const features_t &fish_features() { return global_features; } - -features_t &mutable_fish_features() { return global_features; } +features_t features_t::global_features; const features_t::metadata_t features_t::metadata[features_t::flag_count] = { {stderr_nocaret, L"stderr-nocaret", L"3.0", L"^ no longer redirects stderr"}, diff --git a/src/future_feature_flags.h b/src/future_feature_flags.h index bfc393160..9b3961bde 100644 --- a/src/future_feature_flags.h +++ b/src/future_feature_flags.h @@ -64,19 +64,24 @@ class features_t { /// Return the metadata for a particular name, or nullptr if not found. static const struct metadata_t *metadata_for(const wchar_t *name); + /// The singleton shared feature set. + static features_t global_features; + private: + features_t(); + /// Values for the flags. bool values[flag_count] = {}; }; /// Return the global set of features for fish. This is const to prevent accidental mutation. -const features_t &fish_features(); +inline const features_t &fish_features() { return features_t::global_features; } /// Perform a feature test on the global set of features. inline bool feature_test(features_t::flag_t f) { return fish_features().test(f); } /// Return the global set of features for fish, but mutable. In general fish features should be set /// at startup only. -features_t &mutable_fish_features(); +inline features_t &mutable_fish_features() { return features_t::global_features; } #endif