From 893f6e97661c0a5aab85edf5aa5c60140e371a91 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 20 Aug 2018 20:06:22 -0400 Subject: [PATCH] telemetry_session: Don't allocate std::string instances for program lifetime in GetTelemetryId() and RegenerateTelemetryId() Given these functions aren't intended to be used frequently, there's no need to keep the std::string instances allocated for the whole lifetime of the program. It's just a waste of memory. --- src/core/telemetry_session.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/telemetry_session.cpp b/src/core/telemetry_session.cpp index c553ab62c..ccb954e8a 100644 --- a/src/core/telemetry_session.cpp +++ b/src/core/telemetry_session.cpp @@ -45,7 +45,7 @@ static u64 GenerateTelemetryId() { u64 GetTelemetryId() { u64 telemetry_id{}; - static const std::string& filename{FileUtil::GetUserPath(D_CONFIG_IDX) + "telemetry_id"}; + const std::string filename{FileUtil::GetUserPath(D_CONFIG_IDX) + "telemetry_id"}; if (FileUtil::Exists(filename)) { FileUtil::IOFile file(filename, "rb"); @@ -69,7 +69,7 @@ u64 GetTelemetryId() { u64 RegenerateTelemetryId() { const u64 new_telemetry_id{GenerateTelemetryId()}; - static const std::string& filename{FileUtil::GetUserPath(D_CONFIG_IDX) + "telemetry_id"}; + const std::string filename{FileUtil::GetUserPath(D_CONFIG_IDX) + "telemetry_id"}; FileUtil::IOFile file(filename, "wb"); if (!file.IsOpen()) {