From 14c705349ec745f29eef49f2dbe134c5a33bc998 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Thu, 21 Nov 2024 15:29:52 +0100 Subject: [PATCH] fix: `performance-no-automatic-move` clang-tidy warnings (#44773) * fix: performance-no-automatic-move in GetLogFileName() remove `const` from log_filename. Warning fixed by this commit: ../../electron/shell/common/logging.cc:40:12: warning: constness of 'log_filename' prevents automatic move [performance-no-automatic-move] Co-authored-by: Charles Kerr * fix: performance-no-automatic-move in GetBundleResourcePath() remove `const` from request_relative_path. Warning fixed by this commit: electron/shell/browser/extensions/electron_extensions_browser_client.cc:187:10: warning: constness of 'request_relative_path' prevents automatic move [performance-no-automatic-move] Co-authored-by: Charles Kerr --------- Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Charles Kerr --- .../electron_extensions_browser_client.cc | 2 +- shell/common/logging.cc | 15 ++++++--------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/shell/browser/extensions/electron_extensions_browser_client.cc b/shell/browser/extensions/electron_extensions_browser_client.cc index a355baed888..c23a51d9d93 100644 --- a/shell/browser/extensions/electron_extensions_browser_client.cc +++ b/shell/browser/extensions/electron_extensions_browser_client.cc @@ -174,7 +174,7 @@ base::FilePath ElectronExtensionsBrowserClient::GetBundleResourcePath( if (!chrome_resources_path.IsParent(extension_resources_path)) return base::FilePath(); - const base::FilePath request_relative_path = + base::FilePath request_relative_path = extensions::file_util::ExtensionURLToRelativeFilePath(request.url); if (!ExtensionsBrowserClient::Get() ->GetComponentExtensionResourceManager() diff --git a/shell/common/logging.cc b/shell/common/logging.cc index cc6895ae1b2..1b735fce687 100644 --- a/shell/common/logging.cc +++ b/shell/common/logging.cc @@ -29,16 +29,13 @@ base::FilePath GetLogFileName(const base::CommandLine& command_line) { if (!filename.empty()) return base::FilePath::FromUTF8Unsafe(filename); - const base::FilePath log_filename(FILE_PATH_LITERAL("electron_debug.log")); - base::FilePath log_path; + auto log_filename = base::FilePath{FILE_PATH_LITERAL("electron_debug.log")}; - if (base::PathService::Get(chrome::DIR_LOGS, &log_path)) { - log_path = log_path.Append(log_filename); - return log_path; - } else { - // error with path service, just use some default file somewhere - return log_filename; - } + if (base::FilePath path; base::PathService::Get(chrome::DIR_LOGS, &path)) + return path.Append(log_filename); + + // error with path service, just use some default file somewhere + return log_filename; } namespace {