mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
chore: prefer empty() check for readability (#26159)
This commit is contained in:
@@ -951,7 +951,7 @@ std::vector<v8::Local<v8::Object>> TopLevelWindow::GetChildWindows() const {
|
||||
|
||||
v8::Local<v8::Value> TopLevelWindow::GetBrowserView(
|
||||
gin_helper::Arguments* args) const {
|
||||
if (browser_views_.size() == 0) {
|
||||
if (browser_views_.empty()) {
|
||||
return v8::Null(isolate());
|
||||
} else if (browser_views_.size() == 1) {
|
||||
auto first_view = browser_views_.begin();
|
||||
|
||||
@@ -392,7 +392,7 @@ base::string16 GetDefaultPrinterAsync() {
|
||||
if (printer_name.empty()) {
|
||||
printing::PrinterList printers;
|
||||
print_backend->EnumeratePrinters(&printers);
|
||||
if (printers.size() > 0)
|
||||
if (!printers.empty())
|
||||
printer_name = printers.front().printer_name;
|
||||
}
|
||||
return base::UTF8ToUTF16(printer_name);
|
||||
@@ -2117,7 +2117,7 @@ void WebContents::Print(gin_helper::Arguments* args) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (page_range_list.GetList().size() > 0)
|
||||
if (!page_range_list.GetList().empty())
|
||||
settings.SetPath(printing::kSettingPageRange, std::move(page_range_list));
|
||||
}
|
||||
|
||||
|
||||
@@ -227,7 +227,7 @@ void ElectronBrowserContext::InitPrefs() {
|
||||
auto* current_dictionaries =
|
||||
prefs()->Get(spellcheck::prefs::kSpellCheckDictionaries);
|
||||
// No configured dictionaries, the default will be en-US
|
||||
if (current_dictionaries->GetList().size() == 0) {
|
||||
if (current_dictionaries->GetList().empty()) {
|
||||
std::string default_code = spellcheck::GetCorrespondingSpellCheckLanguage(
|
||||
base::i18n::GetConfiguredLocale());
|
||||
if (!default_code.empty()) {
|
||||
|
||||
@@ -106,7 +106,7 @@ void ElectronDownloadManagerDelegate::OnDownloadPathGenerated(
|
||||
|
||||
if (!settings.parent_window)
|
||||
settings.parent_window = window;
|
||||
if (settings.title.size() == 0)
|
||||
if (settings.title.empty())
|
||||
settings.title = item->GetURL().spec();
|
||||
if (settings.default_path.empty())
|
||||
settings.default_path = default_path;
|
||||
|
||||
@@ -378,7 +378,7 @@ void NativeWindowViews::SetForwardMouseMessages(bool forward) {
|
||||
|
||||
RemoveWindowSubclass(legacy_window_, SubclassProc, 1);
|
||||
|
||||
if (forwarding_windows_.size() == 0) {
|
||||
if (forwarding_windows_.empty()) {
|
||||
UnhookWindowsHookEx(mouse_hook_);
|
||||
mouse_hook_ = NULL;
|
||||
}
|
||||
|
||||
@@ -684,7 +684,7 @@ void OffScreenRenderWidgetHostView::CompositeFrame(
|
||||
SkBitmap frame;
|
||||
|
||||
// Optimize for the case when there is no popup
|
||||
if (proxy_views_.size() == 0 && !popup_host_view_) {
|
||||
if (proxy_views_.empty() && !popup_host_view_) {
|
||||
frame = GetBacking();
|
||||
} else {
|
||||
frame.allocN32Pixels(size_in_pixels.width(), size_in_pixels.height(),
|
||||
|
||||
@@ -148,7 +148,7 @@ int AutofillPopup::GetDesiredPopupWidth() {
|
||||
kEndPadding + 2 * kPopupBorderThickness +
|
||||
gfx::GetStringWidth(GetValueAt(i), GetValueFontListForRow(i)) +
|
||||
gfx::GetStringWidth(GetLabelAt(i), GetLabelFontListForRow(i));
|
||||
if (GetLabelAt(i).length() > 0)
|
||||
if (!GetLabelAt(i).empty())
|
||||
row_size += kNamePadding + kEndPadding;
|
||||
|
||||
popup_width = std::max(popup_width, row_size);
|
||||
|
||||
@@ -161,7 +161,7 @@ DialogResult ShowTaskDialogUTF16(NativeWindow* parent,
|
||||
} else {
|
||||
MapToCommonID(buttons, &id_map, &config.dwCommonButtons, &dialog_buttons);
|
||||
}
|
||||
if (dialog_buttons.size() > 0) {
|
||||
if (!dialog_buttons.empty()) {
|
||||
config.pButtons = &dialog_buttons.front();
|
||||
config.cButtons = dialog_buttons.size();
|
||||
if (!no_link)
|
||||
|
||||
@@ -33,7 +33,7 @@ struct Converter<UUID> {
|
||||
|
||||
UUID uid;
|
||||
|
||||
if (guid.length() > 0) {
|
||||
if (!guid.empty()) {
|
||||
unsigned char* uid_cstr = (unsigned char*)guid.c_str();
|
||||
RPC_STATUS result = UuidFromStringA(uid_cstr, &uid);
|
||||
if (result == RPC_S_INVALID_STRING_UUID) {
|
||||
|
||||
@@ -571,7 +571,7 @@ void OverrideGlobalValueFromIsolatedWorld(
|
||||
const std::vector<std::string>& key_path,
|
||||
v8::Local<v8::Object> value,
|
||||
bool support_dynamic_properties) {
|
||||
if (key_path.size() == 0)
|
||||
if (key_path.empty())
|
||||
return;
|
||||
|
||||
auto* render_frame = GetRenderFrame(value);
|
||||
@@ -603,7 +603,7 @@ bool OverrideGlobalPropertyFromIsolatedWorld(
|
||||
v8::Local<v8::Object> getter,
|
||||
v8::Local<v8::Value> setter,
|
||||
gin_helper::Arguments* args) {
|
||||
if (key_path.size() == 0)
|
||||
if (key_path.empty())
|
||||
return false;
|
||||
|
||||
auto* render_frame = GetRenderFrame(getter);
|
||||
|
||||
Reference in New Issue
Block a user