about summary refs log tree commit diff
path: root/absl/flags/flag.cc
diff options
context:
space:
mode:
Diffstat (limited to 'absl/flags/flag.cc')
-rw-r--r--absl/flags/flag.cc26
1 files changed, 9 insertions, 17 deletions
diff --git a/absl/flags/flag.cc b/absl/flags/flag.cc
index ba002edd24f1..f16cc75e3843 100644
--- a/absl/flags/flag.cc
+++ b/absl/flags/flag.cc
@@ -24,24 +24,16 @@ namespace absl {
 // so in debug builds we always use the slower implementation, which always
 // validates the type.
 #ifndef NDEBUG
-#define ABSL_FLAGS_ATOMIC_GET(T)                              \
-  T GetFlag(const absl::Flag<T>& flag) {                      \
-    T result;                                                 \
-    flag.internal.Read(&result, &flags_internal::FlagOps<T>); \
-    return result;                                            \
-  }
+#define ABSL_FLAGS_ATOMIC_GET(T) \
+  T GetFlag(const absl::Flag<T>& flag) { return flag.Get(); }
 #else
-#define ABSL_FLAGS_ATOMIC_GET(T)                                            \
-  T GetFlag(const absl::Flag<T>& flag) {                                    \
-    const int64_t r = flag.internal.atomic.load(std::memory_order_acquire); \
-    if (r != flags_internal::CommandLineFlag::kAtomicInit) {                \
-      T t;                                                                  \
-      memcpy(&t, &r, sizeof(T));                                            \
-      return t;                                                             \
-    }                                                                       \
-    T result;                                                               \
-    flag.internal.Read(&result, &flags_internal::FlagOps<T>);               \
-    return result;                                                          \
+#define ABSL_FLAGS_ATOMIC_GET(T)         \
+  T GetFlag(const absl::Flag<T>& flag) { \
+    T result;                            \
+    if (flag.AtomicGet(&result)) {       \
+      return result;                     \
+    }                                    \
+    return flag.Get();                   \
   }
 #endif