From 6125590a7b2bbad7d5efdfbab69ba86601e0769b Mon Sep 17 00:00:00 2001
From: Lioncash <mathew1800@gmail.com>
Date: Tue, 20 Apr 2021 12:57:45 -0400
Subject: log/backend: Use in-class initializer for FileBackend

We can also avoid redundant constructions of the same string repeatedly.
---
 src/common/logging/backend.cpp | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

(limited to 'src/common/logging/backend.cpp')

diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp
index f0bb392c64..96efa977d8 100644
--- a/src/common/logging/backend.cpp
+++ b/src/common/logging/backend.cpp
@@ -148,12 +148,14 @@ void ColorConsoleBackend::Write(const Entry& entry) {
     PrintColoredMessage(entry);
 }
 
-FileBackend::FileBackend(const std::string& filename) : bytes_written(0) {
-    if (FS::Exists(filename + ".old.txt")) {
-        FS::Delete(filename + ".old.txt");
+FileBackend::FileBackend(const std::string& filename) {
+    const auto old_filename = filename + ".old.txt";
+
+    if (FS::Exists(old_filename)) {
+        FS::Delete(old_filename);
     }
     if (FS::Exists(filename)) {
-        FS::Rename(filename, filename + ".old.txt");
+        FS::Rename(filename, old_filename);
     }
 
     // _SH_DENYWR allows read only access to the file for other programs.
-- 
cgit v1.2.3-70-g09d2