diff options
author | Abseil Team <absl-team@google.com> | 2020-04-01T14·32-0700 |
---|---|---|
committer | Andy Getz <durandal@google.com> | 2020-04-01T19·19-0400 |
commit | 62f05b1f57ad660e9c09e02ce7d591dcc4d0ca08 (patch) | |
tree | 10a1a50cbca0f6c1d26bab3d5278999979a565b7 /absl/flags | |
parent | fba8a316c30690097de5d6127ad307d84a1b74ca (diff) |
Export of internal Abseil changes
-- 3e6352709da9a529e608eabff862a12bfaecb587 by Gennadiy Rozental <rogeeff@google.com>: Replace local copy of FastTypeId with one shared in absl/base/internal. PiperOrigin-RevId: 304181357 -- c89ea428f732226f4dceb508cd6ba3955a1e49e1 by Andy Getzendanner <durandal@google.com>: Typo fix: add a missing colon. PiperOrigin-RevId: 304064210 -- de2ee7a96bdc7193ffcceb6a2fd6bf464955cbe7 by Samuel Benzaquen <sbenza@google.com>: Reduce the overhead of the registration token by using an empty struct instead of bool. PiperOrigin-RevId: 304054311 -- 222f05d24fb1df7e815946543a7dc78847c83f92 by Derek Mauro <dmauro@google.com>: Turn off hashtablez in opensource builds. Hashtablez is an unsupported, internal-only feature for collecting information about hashtable usage and performance. By turning it off in builds where it is unsupported, we get just a little more performance. PiperOrigin-RevId: 304035460 GitOrigin-RevId: 3e6352709da9a529e608eabff862a12bfaecb587 Change-Id: I0bfe9b5df808a7e35c154b39e6c80e68b0da2b70
Diffstat (limited to 'absl/flags')
-rw-r--r-- | absl/flags/flag.h | 10 | ||||
-rw-r--r-- | absl/flags/internal/flag.h | 8 |
2 files changed, 11 insertions, 7 deletions
diff --git a/absl/flags/flag.h b/absl/flags/flag.h index bb917654d597..4cc8ae373299 100644 --- a/absl/flags/flag.h +++ b/absl/flags/flag.h @@ -333,8 +333,9 @@ ABSL_NAMESPACE_END ABSL_FLAG_IMPL_FLAGNAME(#name), ABSL_FLAG_IMPL_FILENAME(), \ absl::flags_internal::HelpArg<AbslFlagHelpGenFor##name>(0), \ &AbslFlagsInitFlag##name}; \ - extern bool FLAGS_no##name; \ - bool FLAGS_no##name = ABSL_FLAG_IMPL_REGISTRAR(Type, FLAGS_##name) + extern absl::flags_internal::FlagRegistrarEmpty FLAGS_no##name; \ + absl::flags_internal::FlagRegistrarEmpty FLAGS_no##name = \ + ABSL_FLAG_IMPL_REGISTRAR(Type, FLAGS_##name) #else // MSVC version uses aggregate initialization. We also do not try to // optimize away help wrapper. @@ -345,8 +346,9 @@ ABSL_NAMESPACE_END ABSL_CONST_INIT absl::Flag<Type> FLAGS_##name{ \ ABSL_FLAG_IMPL_FLAGNAME(#name), ABSL_FLAG_IMPL_FILENAME(), \ &AbslFlagHelpGenFor##name::NonConst, &AbslFlagsInitFlag##name}; \ - extern bool FLAGS_no##name; \ - bool FLAGS_no##name = ABSL_FLAG_IMPL_REGISTRAR(Type, FLAGS_##name) + extern absl::flags_internal::FlagRegistrarEmpty FLAGS_no##name; \ + absl::flags_internal::FlagRegistrarEmpty FLAGS_no##name = \ + ABSL_FLAG_IMPL_REGISTRAR(Type, FLAGS_##name) #endif // ABSL_RETIRED_FLAG diff --git a/absl/flags/internal/flag.h b/absl/flags/internal/flag.h index c1bf8652815d..ae42dedcd633 100644 --- a/absl/flags/internal/flag.h +++ b/absl/flags/internal/flag.h @@ -648,6 +648,7 @@ void* FlagOps(FlagOp op, const void* v1, void* v2, void* v3) { // This class facilitates Flag object registration and tail expression-based // flag definition, for example: // ABSL_FLAG(int, foo, 42, "Foo help").OnUpdate(NotifyFooWatcher); +struct FlagRegistrarEmpty {}; template <typename T, bool do_register> class FlagRegistrar { public: @@ -660,9 +661,10 @@ class FlagRegistrar { return *this; } - // Make the registrar "die" gracefully as a bool on a line where registration - // happens. Registrar objects are intended to live only as temporary. - operator bool() const { return true; } // NOLINT + // Make the registrar "die" gracefully as an empty struct on a line where + // registration happens. Registrar objects are intended to live only as + // temporary. + operator FlagRegistrarEmpty() const { return {}; } // NOLINT private: Flag<T>* flag_; // Flag being registered (not owned). |