[Lldb-commits] [lldb] [LLDB][NFC] Refactor code extracting timestamp from StructuredData (PR #145954)
Alex Langford via lldb-commits
lldb-commits at lists.llvm.org
Mon Jun 30 10:14:40 PDT 2025
================
@@ -148,23 +161,12 @@ 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");
- }
+ if (auto maybe_start_time = GetAsNanosec(dict, "start_time"))
+ client_info.start_time += *maybe_start_time;
- int64_t end_time;
- if (dict->GetValueForKeyAsInteger("end_time", end_time)) {
+ if (auto maybe_end_time = GetAsNanosec(dict, "end_time")) {
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 + maybe_end_time.value();
----------------
bulbazord wrote:
```suggestion
client_info.end_time = epoch + *maybe_end_time;
```
https://github.com/llvm/llvm-project/pull/145954
More information about the lldb-commits
mailing list