chore: prefer empty() check for readability (#26109)

This commit is contained in:
David Sanders 2020-10-22 13:24:59 -07:00 committed by GitHub
parent d9db9873fd
commit 554ad93d45
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 15 additions and 15 deletions

View file

@ -951,7 +951,7 @@ std::vector<v8::Local<v8::Object>> BaseWindow::GetChildWindows() const {
v8::Local<v8::Value> BaseWindow::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();

View file

@ -406,7 +406,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);
@ -2187,7 +2187,7 @@ void WebContents::Print(gin::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));
}

View file

@ -203,7 +203,7 @@ std::vector<Browser::LaunchItem> GetLoginItemSettingsHelper(
if ((base::CompareCaseInsensitiveASCII(it->Value(), exe.c_str())) == 0) {
Browser::LaunchItem launch_item;
base::string16 launch_path = options.path;
if (!(launch_path.size() > 0)) {
if (launch_path.empty()) {
GetProcessExecPath(&launch_path);
}
launch_item.name = it->Name();
@ -339,7 +339,7 @@ void GetApplicationInfoForProtocolUsingRegistry(
}
const base::string16 app_display_name = GetAppForProtocolUsingRegistry(url);
if (app_display_name.length() == 0) {
if (app_display_name.empty()) {
promise.RejectWithErrorMessage(
"Unable to retrieve application display name");
return;
@ -607,7 +607,7 @@ void Browser::SetLoginItemSettings(LoginItemSettings settings) {
base::win::RegKey startup_approved_key(
HKEY_CURRENT_USER, startup_approved_key_path.c_str(), KEY_ALL_ACCESS);
PCWSTR key_name =
settings.name.size() > 0 ? settings.name.c_str() : GetAppUserModelID();
!settings.name.empty() ? settings.name.c_str() : GetAppUserModelID();
if (settings.open_at_login) {
base::string16 exe = settings.path;

View file

@ -228,7 +228,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()) {

View file

@ -107,7 +107,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;

View file

@ -384,7 +384,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;
}

View file

@ -683,7 +683,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(),

View file

@ -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);

View file

@ -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)

View file

@ -37,7 +37,7 @@ struct Converter<UUID> {
UUID uid;
if (guid.length() > 0) {
if (!guid.empty()) {
if (guid[0] == '{' && guid[guid.length() - 1] == '}') {
guid = guid.substr(1, guid.length() - 2);
}

View file

@ -564,7 +564,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);
@ -596,7 +596,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);