build: enable more performance-* clang-tidy checks (#54024)

* build: enable more performance-* clang-tidy checks

* chore: performance-prefer-single-char-overloads

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* chore: performance-unnecessary-copy-initialization

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* chore: performance-use-std-move

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* chore: performance-move-const-arg

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* chore: performance-no-automatic-move

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* chore: address review feedback

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MC6nEgyED2MtseZ9KdGMpt

* chore: fix new clang-tidy performance findings

Address performance-use-std-move, performance-move-const-arg, and
performance-prefer-single-char-overloads findings in code that landed
on main since the previous base.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MC6nEgyED2MtseZ9KdGMpt

* chore: fix new clang-tidy performance findings on macOS

Silence performance-unnecessary-copy-initialization for task runners
captured by Objective-C blocks in the macOS file and message box
dialogs, matching the existing pattern: the copy is needed since a
block would otherwise capture the reference by reference.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MC6nEgyED2MtseZ9KdGMpt

---------

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
David Babenko-SandersandClaude Opus 5.5 authored and GitHub committed 2026-10-23 14:53:40 -07:00
1 parent bea5390a06
commit 6431970d8b
65 files changed
+149 -112

No files matched your search

+7
View File
@@ -6,6 +6,13 @@ Checks: 'clang-analyzer-core.*,
clang-analyzer-osx.*,
clang-analyzer-security.*,
clang-analyzer-unix.*,
performance-for-range-copy,
performance-implicit-conversion-in-loop,
performance-move-const-arg,
performance-no-automatic-move,
performance-prefer-single-char-overloads,
performance-unnecessary-copy-initialization,
performance-use-std-move,
-bugprone-forward-declaration-namespace,
-clang-analyzer-core.CallAndMessage,
-clang-analyzer-security.PointerSub'
+2 -1
View File
@@ -7,6 +7,7 @@
#include <optional>
#include <string>
#include <string_view>
#include <utility>
#include <vector>
#include "base/command_line.h"
@@ -164,7 +165,7 @@ bool TryGetBundledWidevineCdm(
return false;
}
*cdm_path = cdm_library_path;
*cdm_path = std::move(cdm_library_path);
*capability_out = std::move(capability);
return true;
}
+3 -6
View File
@@ -449,7 +449,7 @@ bool NotificationCallbackWrapper(
const std::vector<uint8_t> additional_data)>& callback,
base::CommandLine cmd,
const base::FilePath& cwd,
const std::vector<uint8_t> additional_data) {
std::vector<uint8_t> additional_data) {
#if BUILDFLAG(IS_LINUX)
// Set the global activation token sent as a command line switch by another
// electron app instance. This also removes the switch after use to prevent
@@ -464,11 +464,8 @@ bool NotificationCallbackWrapper(
if (Browser::Get()->is_ready()) {
callback.Run(std::move(cmd), cwd, std::move(additional_data));
} else {
scoped_refptr<base::SingleThreadTaskRunner> task_runner(
base::SingleThreadTaskRunner::GetCurrentDefault());
// Make a copy of the span so that the data isn't lost.
task_runner->PostTask(
base::SingleThreadTaskRunner::GetCurrentDefault()->PostTask(
FROM_HERE, base::BindOnce(base::IgnoreResult(callback), std::move(cmd),
cwd, std::move(additional_data)));
}
@@ -1105,7 +1102,7 @@ void App::OnSecondInstance(base::CommandLine cmd,
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
v8::HandleScope handle_scope(isolate);
v8::Local<v8::Value> data_value =
DeserializeV8Value(isolate, std::move(additional_data));
DeserializeV8Value(isolate, additional_data);
Emit("second-instance", cmd.argv(), cwd, data_value);
}
+1 -1
View File
@@ -274,7 +274,7 @@ v8::Local<v8::Promise> Clipboard::ReadText(ui::ClipboardBuffer buffer,
return;
}
#endif
promise.Resolve(std::move(result));
promise.Resolve(result);
},
std::move(promise), buffer));
@@ -92,7 +92,7 @@ struct Converter<base::trace_event::TraceConfig> {
base::DictValue memory_dump_config;
if (ConvertFromV8(isolate, val, &memory_dump_config)) {
*out = base::trace_event::TraceConfig(std::move(memory_dump_config));
*out = base::trace_event::TraceConfig(memory_dump_config);
return true;
}
+5 -1
View File
@@ -118,7 +118,11 @@ class Debugger::AgentHostLifecycle final
promise.RejectWithErrorMessage(error_message ? *error_message : "");
} else {
base::DictValue* result = dict.FindDict("result");
promise.Resolve(result ? std::move(*result) : base::DictValue());
if (result) {
promise.Resolve(*result);
} else {
promise.Resolve(base::DictValue());
}
}
}
+4 -4
View File
@@ -266,21 +266,21 @@ std::u16string MenuMac::GetAcceleratorTextAtForTesting(int index) const {
text += u"Ctrl";
if (modifiers & NSEventModifierFlagShift) {
if (!text.empty())
text += u"+";
text += u'+';
text += u"Shift";
}
if (modifiers & NSEventModifierFlagOption) {
if (!text.empty())
text += u"+";
text += u'+';
text += u"Alt";
}
if (modifiers & NSEventModifierFlagCommand) {
if (!text.empty())
text += u"+";
text += u'+';
text += u"Command";
}
if (!text.empty())
text += u"+";
text += u'+';
auto key = base::ToUpperASCII(base::SysNSStringToUTF16([item keyEquivalent]));
if (key == u"\t")
text += u"Tab";
@@ -231,7 +231,7 @@ v8::Local<v8::Promise> SafeStorage::encryptStringAsync(
return handle;
}
pending_encrypts_.emplace_back(std::move(promise), std::move(plaintext));
pending_encrypts_.emplace_back(std::move(promise), plaintext);
return handle;
}
@@ -174,9 +174,8 @@ v8::Local<v8::Value> ServiceWorkerContext::GetAllRunningWorkerInfo(
const base::flat_map<int64_t, content::ServiceWorkerRunningInfo>& info_map =
service_worker_context_->GetRunningServiceWorkerInfos();
for (const auto& iter : info_map) {
builder.Set(
base::NumberToString(iter.first),
ServiceWorkerRunningInfoToDict(isolate, std::move(iter.second)));
builder.Set(base::NumberToString(iter.first),
ServiceWorkerRunningInfoToDict(isolate, iter.second));
}
return builder.Build();
}
@@ -191,8 +190,7 @@ v8::Local<v8::Value> ServiceWorkerContext::GetInfoFromVersionID(
thrower.ThrowError("Could not find service worker with that version_id");
return {};
}
return ServiceWorkerRunningInfoToDict(thrower.isolate(),
std::move(iter->second));
return ServiceWorkerRunningInfoToDict(thrower.isolate(), iter->second);
}
v8::Local<v8::Value> ServiceWorkerContext::GetFromVersionID(
@@ -83,7 +83,7 @@ ServiceWorkerMain* ServiceWorkerMain::FromVersionID(
content::StoragePartitionConfig storage_partition_config,
int64_t version_id) {
const ServiceWorkerKey key{std::move(browser_context_id),
std::move(storage_partition_config), version_id};
storage_partition_config, version_id};
return FromServiceWorkerKey(key);
}
@@ -329,8 +329,7 @@ ServiceWorkerMain* ServiceWorkerMain::From(
content::StoragePartitionConfig storage_partition_config,
int64_t version_id) {
ServiceWorkerKey service_worker_key{std::move(browser_context_id),
std::move(storage_partition_config),
version_id};
storage_partition_config, version_id};
if (auto* service_worker = FromServiceWorkerKey(service_worker_key))
return service_worker;
+1 -2
View File
@@ -1847,8 +1847,7 @@ Session* Session::FromPath(gin::Arguments* args,
return nullptr;
}
browser_context =
ElectronBrowserContext::FromPath(std::move(path), std::move(options));
browser_context = ElectronBrowserContext::FromPath(path, std::move(options));
return FromOrCreate(args->isolate(), browser_context);
}
@@ -179,11 +179,10 @@ void SystemPreferences::PostNotification(const std::string& name,
NSDistributedNotificationCenter* center =
[NSDistributedNotificationCenter defaultCenter];
[center
postNotificationName:base::SysUTF8ToNSString(name)
object:nil
userInfo:DictionaryValueToNSDictionary(std::move(user_info))
deliverImmediately:immediate];
[center postNotificationName:base::SysUTF8ToNSString(name)
object:nil
userInfo:DictionaryValueToNSDictionary(user_info)
deliverImmediately:immediate];
}
int SystemPreferences::SubscribeNotification(
@@ -202,10 +201,9 @@ void SystemPreferences::UnsubscribeNotification(int request_id) {
void SystemPreferences::PostLocalNotification(const std::string& name,
base::DictValue user_info) {
NSNotificationCenter* center = [NSNotificationCenter defaultCenter];
[center
postNotificationName:base::SysUTF8ToNSString(name)
object:nil
userInfo:DictionaryValueToNSDictionary(std::move(user_info))];
[center postNotificationName:base::SysUTF8ToNSString(name)
object:nil
userInfo:DictionaryValueToNSDictionary(user_info)];
}
int SystemPreferences::SubscribeLocalNotification(
@@ -224,10 +222,9 @@ void SystemPreferences::PostWorkspaceNotification(const std::string& name,
base::DictValue user_info) {
NSNotificationCenter* center =
[[NSWorkspace sharedWorkspace] notificationCenter];
[center
postNotificationName:base::SysUTF8ToNSString(name)
object:nil
userInfo:DictionaryValueToNSDictionary(std::move(user_info))];
[center postNotificationName:base::SysUTF8ToNSString(name)
object:nil
userInfo:DictionaryValueToNSDictionary(user_info)];
}
int SystemPreferences::SubscribeWorkspaceNotification(
@@ -248,6 +245,8 @@ int SystemPreferences::DoSubscribeNotification(
const NotificationCallback& callback,
NotificationCenterKind kind) {
int request_id = g_next_id++;
// A copy is needed: the block below would capture a reference by reference.
// NOLINTNEXTLINE(performance-unnecessary-copy-initialization)
__block NotificationCallback copied_callback = callback;
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
@@ -346,7 +345,7 @@ void SystemPreferences::RegisterDefaults(gin::Arguments* args) {
return;
}
@try {
NSDictionary* dict = DictionaryValueToNSDictionary(std::move(dict_value));
NSDictionary* dict = DictionaryValueToNSDictionary(dict_value);
for (id key in dict) {
id value = [dict objectForKey:key];
if ([value isKindOfClass:[NSNull class]] || value == nil) {
@@ -438,7 +438,7 @@ struct Converter<content::NavigationEntry*> {
if (!page_state.IsValid())
return false;
entry->SetPageState(std::move(page_state), restore_context.get());
entry->SetPageState(page_state, restore_context.get());
}
}
@@ -3654,13 +3654,13 @@ void WebContents::DidFinishNavigation(
}
void WebContents::NotifyPageTitleUpdated(
content::NavigationEntry* entry,
const content::NavigationEntry* entry,
bool from_same_document_history_navigation) {
std::u16string final_title;
bool explicit_set = true;
if (entry) {
auto title = entry->GetTitle();
auto url = entry->GetURL();
const auto& title = entry->GetTitle();
const auto& url = entry->GetURL();
if (url.SchemeIsFile() && title.empty()) {
final_title = base::UTF8ToUTF16(url.ExtractFileName());
explicit_set = false;
@@ -4017,7 +4017,7 @@ v8::Local<v8::Promise> WebContents::LoadURL(gin::Arguments* args,
GURL base_url_for_data_url;
if (options.Get("baseURLForDataURL", &base_url_for_data_url)) {
params.base_url_for_data_url = base_url_for_data_url;
params.base_url_for_data_url = std::move(base_url_for_data_url);
params.load_type = content::NavigationController::LOAD_TYPE_DATA;
}
@@ -5884,7 +5884,7 @@ void WebContents::PostMessage(v8::Isolate* isolate,
"webContents has no main frame to post to");
return;
}
frame->PostMessage(isolate, channel, message, std::move(transfer));
frame->PostMessage(isolate, channel, message, transfer);
}
void WebContents::SendInternal(gin::Arguments* args) {
@@ -714,7 +714,7 @@ class WebContents final : public gin::Wrappable<WebContents>,
void DidUpdateFaviconURL(content::RenderFrameHost* render_frame_host,
const std::vector<blink::mojom::FaviconURLPtr>& urls,
blink::mojom::FaviconUpdateReason reason);
void NotifyPageTitleUpdated(content::NavigationEntry* entry,
void NotifyPageTitleUpdated(const content::NavigationEntry* entry,
bool from_same_document_history_navigation);
void MediaStartedPlaying(const MediaPlayerInfo& video_type,
const content::MediaPlayerId& id);
@@ -225,6 +225,11 @@ const gin::WrapperInfo WebRequest::kWrapperInfo =
electron::MakeWrapperInfo(electron::kElectronWebRequest);
WebRequest::RequestFilter::RequestFilter(const RequestFilter&) = default;
WebRequest::RequestFilter::RequestFilter(RequestFilter&&) = default;
WebRequest::RequestFilter& WebRequest::RequestFilter::operator=(
const RequestFilter&) = default;
WebRequest::RequestFilter& WebRequest::RequestFilter::operator=(
RequestFilter&&) = default;
WebRequest::RequestFilter::RequestFilter() = default;
WebRequest::RequestFilter::~RequestFilter() = default;
@@ -949,7 +954,7 @@ WebRequest* WebRequest::Create(
base::PassKey<Session> passkey,
base::WeakPtr<ElectronBrowserContext> browser_context) {
return cppgc::MakeGarbageCollected<WebRequest>(
isolate->GetCppHeap()->GetAllocationHandle(), std::move(passkey),
isolate->GetCppHeap()->GetAllocationHandle(), passkey,
std::move(browser_context));
}
@@ -237,6 +237,9 @@ class WebRequest final : public gin::Wrappable<WebRequest> {
class RequestFilter {
public:
RequestFilter(const RequestFilter&);
RequestFilter(RequestFilter&&);
RequestFilter& operator=(const RequestFilter&);
RequestFilter& operator=(RequestFilter&&);
RequestFilter();
~RequestFilter();
+1 -1
View File
@@ -190,7 +190,7 @@ bool MessagePort::EntanglePorts(v8::Isolate* isolate,
v8::LocalVector<v8::Value> result(isolate);
for (auto& port : channels) {
auto* wrapped_port = MessagePort::Create(isolate);
wrapped_port->Entangle(std::move(port));
wrapped_port->Entangle(port);
v8::Local<v8::Object> wrapper;
if (!wrapped_port->GetWrapper(isolate).ToLocal(&wrapper))
return false;
+2 -1
View File
@@ -6,6 +6,7 @@
#include <string>
#include <string_view>
#include <utility>
#include <vector>
#include "base/files/file_util.h"
@@ -119,7 +120,7 @@ std::optional<AppPackage> LoadAppPackage() {
const base::DictValue& dict = manifest->GetDict();
Apply(dict);
AppPackage package;
package.path = path;
package.path = std::move(path);
const std::string* main = dict.FindString("main");
package.main = main && !main->empty() ? *main : "index.js";
if (const std::string* v8_flags = dict.FindString("v8Flags"))
+1 -1
View File
@@ -81,7 +81,7 @@ bool SetDefaultWebClient(const std::string& protocol) {
if (!found)
return {};
const auto path = base::FilePath::FromUTF8Unsafe(found);
auto path = base::FilePath::FromUTF8Unsafe(found);
g_free(found);
return path;
}
+2 -3
View File
@@ -283,7 +283,7 @@ void Browser::SetUserActivity(const std::string& type,
[[AtomApplication sharedApplication]
setCurrentActivity:base::SysUTF8ToNSString(type)
withUserInfo:DictionaryValueToNSDictionary(std::move(user_info))
withUserInfo:DictionaryValueToNSDictionary(user_info)
withWebpageURL:net::NSURLWithGURL(GURL(url_string))];
}
@@ -305,8 +305,7 @@ void Browser::UpdateCurrentActivity(const std::string& type,
base::DictValue user_info) {
[[AtomApplication sharedApplication]
updateCurrentActivity:base::SysUTF8ToNSString(type)
withUserInfo:DictionaryValueToNSDictionary(
std::move(user_info))];
withUserInfo:DictionaryValueToNSDictionary(user_info)];
}
bool Browser::WillContinueUserActivity(const std::string& type) {
+4 -2
View File
@@ -7,6 +7,8 @@
#include <shlobj.h>
#include <shobjidl.h>
#include <utility>
#include "base/base_paths.h"
#include "base/command_line.h"
#include "base/file_version_info.h"
@@ -605,7 +607,7 @@ void Browser::UpdateBadgeContents(
const std::string& badge_alt_string) {
SkBitmap badge;
if (badge_content) {
std::string content = badge_content.value();
const std::string& content = badge_content.value();
constexpr int kOverlayIconSize = 16;
// This is the color used by the Windows 10 Badge API, for platform
// consistency.
@@ -722,7 +724,7 @@ v8::Local<v8::Value> Browser::GetLoginItemSettings(
launch_items_hklm.end());
settings.executable_will_launch_at_login = executable_will_launch_at_login;
settings.launch_items = launch_items;
settings.launch_items = std::move(launch_items);
return gin::ConvertToV8(JavascriptEnvironment::GetIsolate(), settings);
}
+1 -1
View File
@@ -1813,7 +1813,7 @@ void ElectronBrowserClient::WillCreateURLLoaderFactory(
frame_host ? frame_host->GetRoutingID() : IPC::mojom::kRoutingIdNone,
&next_id_,
std::move(navigation_ui_data),
std::move(navigation_id),
navigation_id,
std::move(proxied_receiver),
std::move(target_factory_remote),
std::move(header_client_receiver),
+1 -1
View File
@@ -393,7 +393,7 @@ ElectronBrowserContext::ElectronBrowserContext(
std::get_if<std::reference_wrapper<const base::FilePath>>(
&partition_location)) {
const base::FilePath& partition_path = filepath_partition->get();
path_ = std::move(partition_path);
path_ = partition_path;
}
BrowserContextDependencyManager::GetInstance()->MarkBrowserContextLive(this);
@@ -274,7 +274,7 @@ void ElectronDownloadManagerDelegate::OnDownloadPathGenerated(
} else {
download::DownloadTargetInfo target_info;
target_info.target_path = path;
target_info.intermediate_path = path;
target_info.intermediate_path = std::move(path);
target_info.target_disposition =
download::DownloadItem::TARGET_DISPOSITION_PROMPT;
target_info.insecure_download_status = item->GetInsecureDownloadStatus();
@@ -316,7 +316,7 @@ void ElectronDownloadManagerDelegate::OnDownloadSaveDialogDone(
: download::DOWNLOAD_INTERRUPT_REASON_NONE;
download::DownloadTargetInfo target_info;
target_info.target_path = path;
target_info.intermediate_path = path;
target_info.intermediate_path = std::move(path);
target_info.target_disposition =
download::DownloadItem::TARGET_DISPOSITION_PROMPT;
target_info.insecure_download_status = item->GetInsecureDownloadStatus();
@@ -348,7 +348,7 @@ bool ElectronDownloadManagerDelegate::DetermineDownloadTarget(
if (!save_path.empty()) {
download::DownloadTargetInfo target_info;
target_info.target_path = save_path;
target_info.intermediate_path = save_path;
target_info.intermediate_path = std::move(save_path);
std::move(*callback).Run(std::move(target_info));
return true;
}
@@ -361,7 +361,7 @@ ExtensionFunction::ResponseAction TabsGetFunction::Run() {
// TODO: Add proper support for split views
tab.split_view_id = -1;
return RespondNow(ArgumentList(tabs::Get::Results::Create(std::move(tab))));
return RespondNow(ArgumentList(tabs::Get::Results::Create(tab)));
}
ExtensionFunction::ResponseAction TabsSetZoomFunction::Run() {
@@ -693,7 +693,7 @@ ExtensionFunction::ResponseValue TabsUpdateFunction::GetResult() {
// TODO: Add proper support for split views
tab.split_view_id = -1;
return ArgumentList(tabs::Get::Results::Create(std::move(tab)));
return ArgumentList(tabs::Get::Results::Create(tab));
}
} // namespace extensions
@@ -130,11 +130,10 @@ bool ElectronComponentExtensionResourceManager::IsComponentExtensionResource(
int* resource_id) const {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
base::FilePath directory_path = extension_path;
base::FilePath resources_dir;
base::FilePath relative_path;
if (!base::PathService::Get(chrome::DIR_RESOURCES, &resources_dir) ||
!resources_dir.AppendRelativePath(directory_path, &relative_path)) {
!resources_dir.AppendRelativePath(extension_path, &relative_path)) {
return false;
}
relative_path = relative_path.Append(resource_path);
+1 -1
View File
@@ -126,7 +126,7 @@ void FileSelectHelper::OnListFile(
void FileSelectHelper::LaunchConfirmationDialog(
const base::FilePath& path,
std::vector<ui::SelectedFileInfo> selected_files) {
ConvertToFileChooserFileInfoList(std::move(selected_files));
ConvertToFileChooserFileInfoList(selected_files);
}
void FileSelectHelper::OnListDone(int error) {
+2 -2
View File
@@ -148,12 +148,12 @@ void LoginHandler::EmitEvent(
// respondToAuthRequestsFromMainProcess. Without a session, auth falls
// through to app.on('login') for backward compatibility.
default_prevented =
utility_process->Emit("login", std::move(details), auth_info,
utility_process->Emit("login", details, auth_info,
base::BindOnce(&LoginHandler::CallbackFromJS,
weak_factory_.GetWeakPtr()));
} else {
default_prevented =
api::App::Get()->Emit("login", nullptr, std::move(details), auth_info,
api::App::Get()->Emit("login", nullptr, details, auth_info,
base::BindOnce(&LoginHandler::CallbackFromJS,
weak_factory_.GetWeakPtr()));
}
+2 -3
View File
@@ -1499,7 +1499,7 @@ bool NativeWindowMac::GetWindowButtonVisibility() const {
void NativeWindowMac::SetWindowButtonPosition(
std::optional<gfx::Point> position) {
traffic_light_position_ = std::move(position);
traffic_light_position_ = position;
if (buttons_proxy_) {
[buttons_proxy_ setMargin:traffic_light_position_];
NotifyLayoutWindowControlsOverlay();
@@ -1550,8 +1550,7 @@ void NativeWindowMac::RefreshTouchBarItem(const std::string& item_id) {
void NativeWindowMac::SetEscapeTouchBarItem(
gin_helper::PersistentDictionary item) {
if (touch_bar_ && [window_ touchBar])
[touch_bar_ setEscapeTouchBarItem:std::move(item)
forTouchBar:[window_ touchBar]];
[touch_bar_ setEscapeTouchBarItem:item forTouchBar:[window_ touchBar]];
}
void NativeWindowMac::SelectPreviousTab() {
+1 -1
View File
@@ -178,7 +178,7 @@ class AsarURLLoader : public network::mojom::URLLoader {
archive->CopyFileOut(relative_path, &unpacked);
info.offset = 0;
if (root.empty()) {
real_path = unpacked;
real_path = std::move(unpacked);
} else if (!base::NormalizeFilePath(unpacked, &real_path) ||
!real_archive.AddExtension(FILE_PATH_LITERAL("unpacked"))
.AppendRelativePath(real_path, &logical) ||
@@ -98,9 +98,9 @@ class ClientCertificateResponderDelegate
mojo::MakeSelfOwnedReceiver(
std::make_unique<SSLPrivateKeyImpl>(private_key),
ssl_private_key.InitWithNewPipeAndPassReceiver());
responder_->ContinueWithCertificate(
std::move(cert), private_key->GetProviderName(),
private_key->GetAlgorithmPreferences(), std::move(ssl_private_key));
responder_->ContinueWithCertificate(cert, private_key->GetProviderName(),
private_key->GetAlgorithmPreferences(),
std::move(ssl_private_key));
}
private:
+1 -1
View File
@@ -207,7 +207,7 @@ void NodeStreamLoader::On(const char* event, EventCallback callback) {
// emitter.on(event, callback)
v8::Local<v8::Value> args[] = {
gin::StringToV8(isolate_, event),
gin_helper::CallbackToV8Leaked(isolate_, std::move(callback)),
gin_helper::CallbackToV8Leaked(isolate_, callback),
};
handlers_[event].Reset(isolate_, args[1]);
node::MakeCallback(isolate_, emitter_.Get(isolate_), "on",
@@ -806,7 +806,7 @@ ProxyingURLLoaderFactory::ProxyingURLLoaderFactory(
frame_routing_id_(frame_routing_id),
request_id_generator_(request_id_generator),
navigation_ui_data_(std::move(navigation_ui_data)),
navigation_id_(std::move(navigation_id)),
navigation_id_(navigation_id),
loader_factory_type_(loader_factory_type) {
target_factory_.Bind(std::move(target_factory_remote));
target_factory_.set_disconnect_handler(base::BindOnce(
+5 -6
View File
@@ -57,18 +57,17 @@ void ResolveHostFunction::Run() {
/*endpoint_results_with_metadata=*/net::HostResolverEndpointResults()));
if (electron::IsUtilityProcess()) {
URLLoaderBundle::GetInstance()->GetHostResolver()->ResolveHost(
network::mojom::HostResolverHost::NewHostPortPair(
std::move(host_port_pair)),
network::mojom::HostResolverHost::NewHostPortPair(host_port_pair),
net::NetworkAnonymizationKey(), std::move(params_),
std::move(resolve_host_client));
} else {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
browser_context_->GetDefaultStoragePartition()
->GetNetworkContext()
->ResolveHost(network::mojom::HostResolverHost::NewHostPortPair(
std::move(host_port_pair)),
net::NetworkAnonymizationKey(), std::move(params_),
std::move(resolve_host_client));
->ResolveHost(
network::mojom::HostResolverHost::NewHostPortPair(host_port_pair),
net::NetworkAnonymizationKey(), std::move(params_),
std::move(resolve_host_client));
}
}
@@ -222,6 +222,8 @@ void CocoaNotification::ScheduleNotification(
LOG(INFO) << "Notification created (" << [identifier UTF8String] << ")";
}
// A copy is needed: the block below would capture a reference by reference.
// NOLINTNEXTLINE(performance-unnecessary-copy-initialization)
scoped_refptr<base::SequencedTaskRunner> task_runner =
base::SequencedTaskRunner::GetCurrentDefault();
auto weak_self = GetWeakPtr();
@@ -78,6 +78,8 @@ Notification* NotificationPresenterMac::CreateNotificationObject(
void NotificationPresenterMac::GetDeliveredNotifications(
GetDeliveredNotificationsCallback callback) {
// A copy is needed: the block below would capture a reference by reference.
// NOLINTNEXTLINE(performance-unnecessary-copy-initialization)
scoped_refptr<base::SequencedTaskRunner> task_runner =
base::SequencedTaskRunner::GetCurrentDefault();
@@ -433,13 +433,13 @@ void HandleToastActivation(const std::wstring& invoked_args,
// Expected invoked_args format:
// type=<click|action|reply>&action=<index>&tag=<hash> Parse simple key=value
// pairs separated by '&'.
std::wstring args = invoked_args;
std::wstring type;
std::wstring action_index_str;
std::wstring tag_str;
for (const auto& token : base::SplitString(args, L"&", base::KEEP_WHITESPACE,
base::SPLIT_WANT_NONEMPTY)) {
for (const auto& token :
base::SplitString(invoked_args, L"&", base::KEEP_WHITESPACE,
base::SPLIT_WANT_NONEMPTY)) {
auto kv = base::SplitString(token, L"=", base::KEEP_WHITESPACE,
base::SPLIT_WANT_NONEMPTY);
if (kv.size() != 2)
+1 -1
View File
@@ -223,7 +223,7 @@ bool Converter<PreloadScript>::FromV8(v8::Isolate* isolate,
return false;
}
if (base::FilePath file_path; options.Get("filePath", &file_path)) {
out->file_path = file_path;
out->file_path = std::move(file_path);
} else {
return false;
}
+1 -1
View File
@@ -184,7 +184,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
identifier = [self identifierFromID:item_id type:type];
}
if (identifier) {
[self addNonDefaultTouchBarItems:{std::move(item)}];
[self addNonDefaultTouchBarItems:{item}];
touchBar.escapeKeyReplacementItemIdentifier = identifier;
} else {
touchBar.escapeKeyReplacementItemIdentifier = nil;
@@ -89,7 +89,7 @@ void BundledDataSource::StartDataRequest(
const std::string path = content::URLDataSource::URLToRequestPath(url);
// Serve request from local bundle.
std::string bundled_path_prefix(chrome::kChromeUIDevToolsBundledPath);
bundled_path_prefix += "/";
bundled_path_prefix += '/';
if (base::StartsWith(path, bundled_path_prefix,
base::CompareCase::INSENSITIVE_ASCII)) {
StartBundledDataRequest(path.substr(bundled_path_prefix.length()),
+4
View File
@@ -524,6 +524,8 @@ void ShowOpenDialogForNSWindow(const DialogSettings& settings,
SetupOpenDialogForProperties(dialog, settings.properties);
__block OpenDialogCallback cb = std::move(callback);
// A copy is needed: the block below would capture a reference by reference.
// NOLINTNEXTLINE(performance-unnecessary-copy-initialization)
scoped_refptr<base::SequencedTaskRunner> task_runner =
base::SequencedTaskRunner::GetCurrentDefault();
[dialog
@@ -643,6 +645,8 @@ void ShowSaveDialogForNSWindow(const DialogSettings& settings,
[dialog setCanSelectHiddenExtension:YES];
__block SaveDialogCallback cb = std::move(callback);
// A copy is needed: the block below would capture a reference by reference.
// NOLINTNEXTLINE(performance-unnecessary-copy-initialization)
scoped_refptr<base::SequencedTaskRunner> task_runner =
base::SequencedTaskRunner::GetCurrentDefault();
[dialog
+1 -1
View File
@@ -120,7 +120,7 @@ bool IsLocalDevToolsFrontendURL(const GURL& url) {
return false;
}
std::string_view path = url.path();
if (path.starts_with("/")) {
if (path.starts_with('/')) {
path = path.substr(1);
}
return path.starts_with(chrome::kChromeUIDevToolsBundledPath) ||
+3 -1
View File
@@ -174,8 +174,10 @@ void ShowMessageBoxForNSWindow(const MessageBoxSettings& settings,
// Duplicate the callback object here since c is a reference and gcd would
// only store the pointer, by duplication we can force gcd to store a copy.
__block MessageBoxCallback callback_ = std::move(callback);
__block std::optional<int> id = std::move(settings.id);
__block std::optional<int> id = settings.id;
__block int cancel_id = settings.cancel_id;
// A copy is needed: the block below would capture a reference by reference.
// NOLINTNEXTLINE(performance-unnecessary-copy-initialization)
scoped_refptr<base::SequencedTaskRunner> task_runner =
base::SequencedTaskRunner::GetCurrentDefault();
@@ -8,6 +8,7 @@
#include <array>
#include <cmath>
#include <string>
#include <utility>
#include "base/check.h"
#include "base/memory/ptr_util.h"
@@ -221,7 +222,7 @@ class FreedesktopButtonImageSource : public gfx::ImageSkiaSource {
scaled.eraseColor(SK_ColorTRANSPARENT);
bitmap.pixmap().scalePixels(
scaled.pixmap(), SkSamplingOptions(SkCubicResampler::Mitchell()));
bitmap = scaled;
bitmap = std::move(scaled);
}
return gfx::ImageSkiaRep(bitmap, scale);
+1 -1
View File
@@ -348,7 +348,7 @@ std::string RecursiveDumpAXPlatformNodeAsString(
str += attribute + " ";
}
}
str += "\n";
str += '\n';
for (size_t i = 0, child_count = node_delegate->GetChildCount();
i < child_count; i++) {
gfx::NativeViewAccessible child = node_delegate->ChildAtIndex(i);
+3 -1
View File
@@ -6,6 +6,8 @@
#include <objbase.h>
#include <utility>
#include "base/logging.h"
#include "base/strings/string_util_win.h"
#include "base/strings/utf_string_conversions.h"
@@ -240,7 +242,7 @@ void NotifyIcon::CloseContextMenu() {
}
void NotifyIcon::SetContextMenu(raw_ptr<ElectronMenuModel> menu_model) {
menu_model_ = menu_model;
menu_model_ = std::move(menu_model);
}
gfx::Rect NotifyIcon::GetBounds() {
@@ -207,7 +207,7 @@ bool NativeImage::TryConvertNativeImage(v8::Isolate* isolate,
#if BUILDFLAG(IS_WIN)
const auto img_path = base::WideToUTF8(icon_path.value());
#else
const auto img_path = icon_path.value();
const auto& img_path = icon_path.value();
#endif
error_message = "Failed to load image from path '" + img_path + "'";
}
@@ -37,8 +37,7 @@ v8::Local<v8::Promise> NativeImage::CreateThumbnailFromPath(
// create an IShellItem
Microsoft::WRL::ComPtr<IShellItem> pItem;
std::wstring image_path = path.value();
hr = SHCreateItemFromParsingName(image_path.c_str(), nullptr,
hr = SHCreateItemFromParsingName(path.value().c_str(), nullptr,
IID_PPV_ARGS(&pItem));
if (FAILED(hr)) {
+1 -1
View File
@@ -159,7 +159,7 @@ v8::Local<v8::Value> CompileWasmModuleWithCacheForTesting(
std::span(cached_bytes.span().data(), cached_bytes.span().size()));
},
[resolve = std::move(resolve)](ModuleResult result) {
resolve.Run(std::move(result));
resolve.Run(result);
});
auto result = gin_helper::Dictionary::CreateEmpty(isolate);
result.Set("accepted", accepted);
+5
View File
@@ -183,6 +183,11 @@ bool FillFileInfoWithNode(Archive::FileInfo* info,
IntegrityPayload::IntegrityPayload() = default;
IntegrityPayload::~IntegrityPayload() = default;
IntegrityPayload::IntegrityPayload(const IntegrityPayload& other) = default;
IntegrityPayload::IntegrityPayload(IntegrityPayload&& other) = default;
IntegrityPayload& IntegrityPayload::operator=(const IntegrityPayload& other) =
default;
IntegrityPayload& IntegrityPayload::operator=(IntegrityPayload&& other) =
default;
Archive::FileInfo::FileInfo() = default;
Archive::FileInfo::~FileInfo() = default;
+3
View File
@@ -34,6 +34,9 @@ struct IntegrityPayload {
IntegrityPayload();
~IntegrityPayload();
IntegrityPayload(const IntegrityPayload& other);
IntegrityPayload(IntegrityPayload&& other);
IntegrityPayload& operator=(const IntegrityPayload& other);
IntegrityPayload& operator=(IntegrityPayload&& other);
HashAlgorithm algorithm = HashAlgorithm::kNone;
std::string hash;
uint32_t block_size = 0U;
+2 -1
View File
@@ -4,6 +4,7 @@
#include "shell/common/asar/scoped_temporary_file.h"
#include <utility>
#include <vector>
#include "base/files/file_util.h"
@@ -42,7 +43,7 @@ bool ScopedTemporaryFile::Init(const base::FilePath::StringType& ext) {
base::FilePath new_path = path_.AddExtension(ext);
if (!base::Move(path_, new_path))
return false;
path_ = new_path;
path_ = std::move(new_path);
}
#endif
+3 -1
View File
@@ -4,6 +4,8 @@
#include "shell/common/electron_paths.h"
#include <utility>
#include "base/environment.h"
#include "base/files/file_util.h"
#include "base/path_service.h"
@@ -102,7 +104,7 @@ bool ElectronPathProvider(int key, base::FilePath* result) {
return false;
}
*result = cur;
*result = std::move(cur);
return true;
}
+2 -1
View File
@@ -38,6 +38,7 @@
#include <sstream>
#include <string>
#include <string_view>
#include <utility>
#include <vector>
#include "libplatform/libplatform.h"
@@ -248,7 +249,7 @@ bool ParseBlobAt(std::string_view data, size_t offset, BlobInfo* info) {
static_cast<uInt>(b.size - kSnapRoChecksumOffset));
b.checksum_ok = static_cast<uint32_t>(a) == ReadU32(p + kSnapChecksumOffset);
b.ro_checksum = ReadU32(p + kSnapRoChecksumOffset);
*info = b;
*info = std::move(b);
return true;
}
+1 -1
View File
@@ -58,7 +58,7 @@ bool CertFromData(const std::string& data,
if (cert_list.empty())
return false;
auto leaf_cert = cert_list.front();
const auto& leaf_cert = cert_list.front();
if (!leaf_cert)
return false;
+1 -1
View File
@@ -69,7 +69,7 @@ class CallbackHolder final : public gin::internal::CallbackHolderBase {
: gin::internal::CallbackHolderBase(
reinterpret_cast<uintptr_t>(&kSignatureId<Sig>)),
callback(std::move(callback)),
invoker_options(std::move(invoker_options)) {}
invoker_options(invoker_options) {}
CallbackHolder(const CallbackHolder&) = delete;
CallbackHolder& operator=(const CallbackHolder&) = delete;
+1 -1
View File
@@ -82,7 +82,7 @@ gin::ObjectTemplateBuilder ReplyChannel::GetObjectTemplateBuilder(
}
bool ReplyChannel::SendReply(v8::Isolate* isolate, v8::Local<v8::Value> arg) {
return SendReplyImpl(isolate, callback_, std::move(arg));
return SendReplyImpl(isolate, callback_, arg);
}
void ReplyChannel::EnsureReplySent() {
+1 -1
View File
@@ -937,7 +937,7 @@ std::shared_ptr<node::Environment> NodeBindings::CreateEnvironment(
if (browser_env_ == BrowserEnvironment::kBrowser ||
browser_env_ == BrowserEnvironment::kRenderer) {
if (on_app_code_ready) {
process.SetMethod("appCodeLoaded", std::move(*on_app_code_ready));
process.SetMethod("appCodeLoaded", *on_app_code_ready);
} else {
process.SetMethod("appCodeLoaded",
base::BindRepeating(&NodeBindings::SetAppCodeLoaded,
+2 -2
View File
@@ -262,7 +262,7 @@ class ShowItemHelper {
// Unretained is safe, the ShowItemHelper instance is
// never destroyed.
base::Unretained(this), full_path),
std::move(file_to_highlight), /*startup-id=*/"");
file_to_highlight, /*startup-id=*/"");
}
void ShowItemUsingFileManagerResponse(
@@ -320,7 +320,7 @@ bool XDGUtil(const std::vector<std::string>& argv,
base::nix::CreateLaunchOptionsWithXdgActivation(base::BindOnce(
[](base::RepeatingClosure quit_loop, base::LaunchOptions* options_out,
base::LaunchOptions options) {
*options_out = std::move(options);
*options_out = options;
std::move(quit_loop).Run();
},
std::move(quit_loop), &options));
+2
View File
@@ -131,6 +131,8 @@ void OpenExternal(const GURL& url,
configuration.activates = options.activate;
__block OpenCallback copied_callback = std::move(callback);
// A copy is needed: the block below would capture a reference by reference.
// NOLINTNEXTLINE(performance-unnecessary-copy-initialization)
scoped_refptr<base::SequencedTaskRunner> runner =
base::SequencedTaskRunner::GetCurrentDefault();
@@ -862,7 +862,7 @@ void OverrideGlobalValueFromIsolatedWorld(
v8::Local<v8::Context> main_context = frame->MainWorldScriptContext();
gin_helper::Dictionary global(isolate, main_context->Global());
const std::string final_key = key_path[key_path.size() - 1];
const std::string& final_key = key_path[key_path.size() - 1];
auto maybe_target_object =
TraceKeyPath(global, key_path, allow_silent_failure);
if (!maybe_target_object.has_value())
@@ -899,7 +899,7 @@ bool OverrideGlobalPropertyFromIsolatedWorld(
v8::Local<v8::Context> main_context = frame->MainWorldScriptContext();
gin_helper::Dictionary global(isolate, main_context->Global());
const std::string final_key = key_path[key_path.size() - 1];
const std::string& final_key = key_path[key_path.size() - 1];
auto target_dict = TraceKeyPath(global, key_path, false);
v8::Local<v8::Object> target_object = target_dict.value().GetHandle();
+1 -1
View File
@@ -234,7 +234,7 @@ void ElectronApiServiceImpl::ReceivePostMessage(
for (auto& port : message.ports) {
ports.emplace_back(
blink::WebMessagePortConverter::EntangleAndInjectMessagePortChannel(
isolate, context, std::move(port)));
isolate, context, port));
}
std::vector<v8::Local<v8::Value>> args = {message_value};
+1 -1
View File
@@ -461,7 +461,7 @@ bool RendererClientBase::OverrideCreatePlugin(
blink::WebPlugin** plugin) {
#if BUILDFLAG(ENABLE_PDF_VIEWER)
if (params.mime_type.Utf8() == pdf::kInternalPluginMimeType) {
*plugin = pdf::CreateInternalPlugin(std::move(params), render_frame, {});
*plugin = pdf::CreateInternalPlugin(params, render_frame, {});
return true;
}
#endif // BUILDFLAG(ENABLE_PDF_VIEWER)
@@ -710,7 +710,7 @@ void UtilityAILanguageModel::MeasureInputUsage(
if (result->IsNumber() &&
gin::ConvertFromV8(isolate, result, &input_tokens)) {
std::move(callback).Run(std::move(input_tokens));
std::move(callback).Run(input_tokens);
} else if (result->IsNull()) {
std::move(callback).Run(std::nullopt);
} else {
+1 -1
View File
@@ -404,7 +404,7 @@ void UtilityAIManager::CreateLanguageModel(
CreateLanguageModelInternal(isolate, std::move(client),
language_model_class.Get(isolate), "create",
std::move(options_dict), std::move(options));
options_dict, std::move(options));
}
void UtilityAIManager::CreateLanguageModelInternal(