From 706fed3bf4f57f00d8a2da5c044e5322b39ece19 Mon Sep 17 00:00:00 2001 From: Andrey Semashev Date: Thu, 7 May 2020 17:48:38 +0300 Subject: [PATCH] Avoid unnecessary copy of the filename string. --- src/text_file_backend.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/text_file_backend.cpp b/src/text_file_backend.cpp index 1fbf0c2..dd60085 100644 --- a/src/text_file_backend.cpp +++ b/src/text_file_backend.cpp @@ -773,8 +773,8 @@ BOOST_LOG_ANONYMOUS_NAMESPACE { info.m_TimeStamp = filesystem::last_write_time(src_path); info.m_Size = filesystem::file_size(src_path); - filesystem::path file_name_path = src_path.filename(); - path_string_type file_name = file_name_path.native(); + const filesystem::path file_name_path = src_path.filename(); + path_string_type const& file_name = file_name_path.native(); info.m_Path = m_StorageDir / file_name_path; // Check if the file is already in the target directory @@ -862,7 +862,7 @@ BOOST_LOG_ANONYMOUS_NAMESPACE { if (m_MinFreeSpace) free_space = filesystem::space(m_StorageDir).available; m_TotalSize -= old_info.m_Size; - m_Files.erase(it++); + it = m_Files.erase(it); } catch (system::system_error&) { @@ -874,7 +874,7 @@ BOOST_LOG_ANONYMOUS_NAMESPACE { { // If it's not a file or is absent, just remove it from the list m_TotalSize -= old_info.m_Size; - m_Files.erase(it++); + it = m_Files.erase(it); } }