[Lldb-commits] [lldb] [LLDB][NFC] Refactor code extracting timestamp from StructuredData (PR #145954)

Alex Langford via lldb-commits lldb-commits at lists.llvm.org
Thu Jun 26 13:46:08 PDT 2025


================
@@ -148,23 +161,14 @@ void TelemetryManager::DispatchClientTelemetry(
     LLDB_LOG(GetLog(LLDBLog::Object),
              "Cannot determine client_data from client-telemetry entry");
 
-  int64_t start_time;
-  if (dict->GetValueForKeyAsInteger("start_time", start_time)) {
-    client_info.start_time +=
-        std::chrono::nanoseconds(static_cast<size_t>(start_time));
-  } else {
-    LLDB_LOG(GetLog(LLDBLog::Object),
-             "Cannot determine start-time from client-telemetry entry");
-  }
+  auto start_time = GetAsNanosec(dict, "start_time");
+  if (start_time.has_value())
+    client_info.start_time += start_time.value();
 
-  int64_t end_time;
-  if (dict->GetValueForKeyAsInteger("end_time", end_time)) {
+  auto end_time = GetAsNanosec(dict, "end_time");
+  if (end_time.has_value()) {
     SteadyTimePoint epoch;
-    client_info.end_time =
-        epoch + std::chrono::nanoseconds(static_cast<size_t>(end_time));
-  } else {
-    LLDB_LOG(GetLog(LLDBLog::Object),
-             "Cannot determine end-time from client-telemetry entry");
+    client_info.end_time = epoch + end_time.value();
----------------
bulbazord wrote:

Same suggestion here.

https://github.com/llvm/llvm-project/pull/145954


More information about the lldb-commits mailing list