From 62f05b1f57ad660e9c09e02ce7d591dcc4d0ca08 Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Wed, 1 Apr 2020 07:32:27 -0700 Subject: Export of internal Abseil changes -- 3e6352709da9a529e608eabff862a12bfaecb587 by Gennadiy Rozental : Replace local copy of FastTypeId with one shared in absl/base/internal. PiperOrigin-RevId: 304181357 -- c89ea428f732226f4dceb508cd6ba3955a1e49e1 by Andy Getzendanner : Typo fix: add a missing colon. PiperOrigin-RevId: 304064210 -- de2ee7a96bdc7193ffcceb6a2fd6bf464955cbe7 by Samuel Benzaquen : Reduce the overhead of the registration token by using an empty struct instead of bool. PiperOrigin-RevId: 304054311 -- 222f05d24fb1df7e815946543a7dc78847c83f92 by Derek Mauro : 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 --- absl/flags/flag.h | 10 ++++++---- absl/flags/internal/flag.h | 8 +++++--- 2 files changed, 11 insertions(+), 7 deletions(-) (limited to 'absl/flags') diff --git a/absl/flags/flag.h b/absl/flags/flag.h index bb917654..4cc8ae37 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(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 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 c1bf8652..ae42dedc 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 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* flag_; // Flag being registered (not owned). -- cgit v1.2.3