Skip to content

Commit

Permalink
Pure pedantry: Replace all ".size() == 0" with ".empty()".
Browse files Browse the repository at this point in the history
BUG=carnitas
TEST=compiles; existing unit tests.

Review URL: http://codereview.chromium.org/6602049

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@76467 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
erg@google.com committed Mar 2, 2011
1 parent 9ad7709 commit f6b8ce3
Show file tree
Hide file tree
Showing 59 changed files with 76 additions and 76 deletions.
2 changes: 1 addition & 1 deletion base/command_line_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ TEST(CommandLineTest, EmptyString) {
EXPECT_TRUE(cl.GetProgram().empty());
#elif defined(OS_POSIX)
CommandLine cl(0, NULL);
EXPECT_TRUE(cl.argv().size() == 0);
EXPECT_EQ(0U, cl.argv().size());
#endif
EXPECT_EQ(0U, cl.args().size());
}
Expand Down
2 changes: 1 addition & 1 deletion base/crypto/encryptor_nss.cc
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ bool Encryptor::Encrypt(const std::string& plaintext, std::string* ciphertext) {
}

bool Encryptor::Decrypt(const std::string& ciphertext, std::string* plaintext) {
if (ciphertext.size() == 0)
if (ciphertext.empty())
return false;

ScopedPK11Context context(PK11_CreateContextBySymKey(CKM_AES_CBC_PAD,
Expand Down
2 changes: 1 addition & 1 deletion base/file_path.cc
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ bool FilePath::AppendRelativePath(const FilePath& child,

if (parent_components.size() >= child_components.size())
return false;
if (parent_components.size() == 0)
if (parent_components.empty())
return false;

std::vector<StringType>::const_iterator parent_comp =
Expand Down
2 changes: 1 addition & 1 deletion base/file_util_posix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ FileEnumerator::FileEnumerator(const FilePath& root_path,
// The Windows version of this code appends the pattern to the root_path,
// potentially only matching against items in the top-most directory.
// Do the same here.
if (pattern.size() == 0)
if (pattern.empty())
pattern_ = FilePath::StringType();
pending_paths_.push(root_path);
}
Expand Down
2 changes: 1 addition & 1 deletion base/mime_util_xdg.cc
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ FilePath LookupIconInDefaultTheme(const std::string& icon_name, int size) {
EnsureUpdated();
MimeUtilConstants* constants = MimeUtilConstants::GetInstance();
std::map<std::string, IconTheme*>* icon_themes = constants->icon_themes_;
if (icon_themes->size() == 0)
if (icon_themes->empty())
InitDefaultThemes();

FilePath icon_path;
Expand Down
2 changes: 1 addition & 1 deletion base/process_util_posix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ char** AlterEnvironment(const environment_vector& changes,
// Now handle new elements
for (environment_vector::const_iterator
j = changes.begin(); j != changes.end(); j++) {
if (j->second.size() == 0)
if (j->second.empty())
continue;

bool found = false;
Expand Down
2 changes: 1 addition & 1 deletion base/string_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,7 @@ size_t Tokenize(const base::StringPiece& str,
template<typename STR>
static STR JoinStringT(const std::vector<STR>& parts,
typename STR::value_type sep) {
if (parts.size() == 0) return STR();
if (parts.empty()) return STR();

STR result(parts[0]);
typename std::vector<STR>::const_iterator iter = parts.begin();
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/autocomplete/autocomplete_popup_view_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@
}

// If everything was elided away, clear the string.
if (elided.size() == 0) {
if (elided.empty()) {
[aString deleteCharactersInRange:NSMakeRange(0, [aString length])];
return aString;
}
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/bookmarks/bookmark_pasteboard_helper_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ void WriteToClipboardPrivate(
const std::vector<BookmarkNodeData::Element>& elements,
NSPasteboard* pb,
FilePath::StringType profile_path) {
if (elements.size() == 0) {
if (elements.empty()) {
return;
}
NSArray* types = [NSArray arrayWithObjects:kBookmarkDictionaryListPboardType,
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/browser_about_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,7 @@ void AboutMemoryHandler::OnDetailsAvailable() {
// Aggregate per-process data into browser summary data.
std::wstring log_string;
for (size_t index = 0; index < browser_processes.size(); index++) {
if (browser_processes[index].processes.size() == 0)
if (browser_processes[index].processes.empty())
continue;

// Sum the information for the processes within this browser.
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/chromeos/network_message_observer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ void NetworkMessageObserver::OnCellularDataPlanChanged(NetworkLibrary* cros) {
cros->GetDataPlans(cellular->service_path());

// If no plans available, check to see if we need a new plan.
if (!plans || plans->size() == 0) {
if (!plans || plans->empty()) {
// If previously, we had a low data notification, we know that a plan was
// near expiring. In that case, because the plan has disappeared, we assume
// that it expired.
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/debugger/debugger_remote_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ void DebuggerRemoteService::HandleMessage(
content->GetString(kCommandKey, &command);
response.SetString(kCommandKey, command);
bool send_response = true;
if (destination.size() == 0) {
if (destination.empty()) {
// Unknown command (bad format?)
NOTREACHED();
response.SetInteger(kResultKey, RESULT_UNKNOWN_COMMAND);
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/debugger/devtools_remote_listen_socket.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void DevToolsRemoteListenSocket::StartNextField() {
state_ = HEADERS;
break;
case HEADERS:
if (protocol_field_.size() == 0) { // empty line - end of headers
if (protocol_field_.empty()) { // empty line - end of headers
const std::string& payload_length_string = GetHeader(
DevToolsRemoteMessageHeaders::kContentLength, "0");
base::StringToInt(payload_length_string, &remaining_payload_length_);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ bool DevToolsRemoteListenSocketTester::NextAction(int timeout) {
if (ret != WAIT_OBJECT_0)
return false;
EnterCriticalSection(&lock_);
if (queue_.size() == 0) {
if (queue_.empty()) {
LeaveCriticalSection(&lock_);
return false;
}
Expand All @@ -197,7 +197,7 @@ bool DevToolsRemoteListenSocketTester::NextAction(int timeout) {
break;
}
pthread_mutex_lock(&lock_);
if (queue_.size() == 0) {
if (queue_.empty()) {
pthread_mutex_unlock(&lock_);
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/extensions/extension_tabs_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ bool CreateWindowFunction::RunImpl() {
TabStripModel* target_tab_strip = new_window->tabstrip_model();
target_tab_strip->InsertTabContentsAt(urls.size(), contents,
TabStripModel::ADD_NONE);
} else if (urls.size() == 0) {
} else if (urls.empty()) {
new_window->NewTab();
}
new_window->SelectNumberedTab(0);
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/extensions/user_script_master.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ static bool GetDeclarationValue(const base::StringPiece& line,
std::string temp(line.data() + index + prefix.length(),
line.length() - index - prefix.length());

if (temp.size() == 0 || !IsWhitespace(temp[0]))
if (temp.empty() || !IsWhitespace(temp[0]))
return false;

TrimWhitespaceASCII(temp, TRIM_ALL, value);
Expand Down Expand Up @@ -125,7 +125,7 @@ bool UserScriptMaster::ScriptReloader::ParseMetadataHeader(

// If no patterns were specified, default to @include *. This is what
// Greasemonkey does.
if (script->globs().size() == 0 && script->url_patterns().size() == 0)
if (script->globs().empty() && script->url_patterns().empty())
script->add_glob("*");

return true;
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/history/history_backend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ void HistoryBackend::AddPage(scoped_refptr<HistoryAddPageArgs> request) {

// If a redirect chain is given, we expect the last item in that chain to be
// the final URL.
DCHECK(request->redirects.size() == 0 ||
DCHECK(request->redirects.empty() ||
request->redirects.back() == request->url);

// Avoid duplicating times in the database, at least as long as pages are
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/history/text_database.cc
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ void TextDatabase::GetTextMatches(const std::string& query,
// When we have returned all the results possible (or determined that there
// are none), then we have searched all the time requested, so we can
// set the first_time_searched to that value.
if (results->size() == 0 ||
if (results->empty() ||
options.max_count == 0 || // Special case for wanting all the results.
static_cast<int>(results->size()) < options.max_count) {
*first_time_searched = options.begin_time;
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/password_manager/password_store_mac.cc
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ std::vector<PasswordForm*> GetPasswordsForForms(
std::vector<PasswordForm*> keychain_matches =
keychain_adapter.PasswordsMergeableWithForm(**i);
MergePasswordForms(&keychain_matches, &db_form_container, &merged_forms);
if (db_form_container.size() == 0) {
if (db_form_container.empty()) {
i = database_forms->erase(i);
} else {
++i;
Expand Down Expand Up @@ -626,7 +626,7 @@ SecKeychainItemRef MacKeychainPasswordFormAdapter::KeychainItemForForm(
std::vector<SecKeychainItemRef> matches = MatchingKeychainItems(
form.signon_realm, form.scheme, path.c_str(), username.c_str());

if (matches.size() == 0) {
if (matches.empty()) {
return NULL;
}
// Free all items after the first, since we won't be returning them.
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/process_info_snapshot_mac.cc
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ static bool GetProcessMemoryInfoUsingTop(
if (in.fail())
break;

if (unit.size() == 0)
if (unit.empty())
break;

uint64_t scale;
Expand Down Expand Up @@ -346,7 +346,7 @@ bool ProcessInfoSnapshot::Sample(std::vector<base::ProcessId> pid_list) {
Reset();

// Nothing to do if no PIDs given.
if (pid_list.size() == 0)
if (pid_list.empty())
return true;
if (pid_list.size() > kMaxPidListSize) {
// The spec says |pid_list| *must* not have more than this many entries.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ class VisitedLinkUpdater {
return;
}

if (pending_.size() == 0)
if (pending_.empty())
return;

sender->Send(new ViewMsg_VisitedLink_Add(pending_));
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/renderer_host/web_cache_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ void WebCacheManager::AddToStrategy(const std::set<int>& renderers,

// Nothing to do if there are no renderers. It is common for there to be no
// inactive renderers if there is a single active tab.
if (renderers.size() == 0)
if (renderers.empty())
return;

// Divide the extra memory evenly among the renderers.
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/speech/speech_input_bubble_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ SpeechInputBubbleController::SpeechInputBubbleController(Delegate* delegate)
}

SpeechInputBubbleController::~SpeechInputBubbleController() {
DCHECK(bubbles_.size() == 0);
DCHECK(bubbles_.empty());
}

void SpeechInputBubbleController::CreateBubble(int caller_id,
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/sync/glue/data_type_manager_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ void DataTypeManagerImpl::Configure(const TypeSet& desired_types) {
SortComparator(&start_order_));

// If nothing changed, we're done.
if (needs_start_.size() == 0 && needs_stop_.size() == 0) {
if (needs_start_.empty() && needs_stop_.empty()) {
state_ = CONFIGURED;
NotifyStart();
NotifyDone(OK);
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/sync/glue/data_type_manager_impl2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ void DataTypeManagerImpl2::Configure(const TypeSet& desired_types) {
SortComparator(&start_order_));

// If nothing changed, we're done.
if (needs_start_.size() == 0 && needs_stop_.size() == 0) {
if (needs_start_.empty() && needs_stop_.empty()) {
state_ = CONFIGURED;
NotifyStart();
NotifyDone(OK);
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/tab_contents/render_view_context_menu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ void RenderViewContextMenu::RecursivelyAppendExtensionItems(
ExtensionMenuItem::List children =
GetRelevantExtensionItems(item->children(), params_,
profile_, can_cross_incognito);
if (children.size() == 0) {
if (children.empty()) {
menu_model->AddItem(menu_id, title);
} else {
ui::SimpleMenuModel* submenu = new ui::SimpleMenuModel(this);
Expand Down Expand Up @@ -720,7 +720,7 @@ void RenderViewContextMenu::AppendEditableItems() {

// If word is misspelled, give option for "Add to dictionary"
if (!params_.misspelled_word.empty()) {
if (params_.dictionary_suggestions.size() == 0) {
if (params_.dictionary_suggestions.empty()) {
menu_model_.AddItem(0,
l10n_util::GetStringUTF16(
IDS_CONTENT_CONTEXT_NO_SPELLING_SUGGESTIONS));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ void UpdateBB3() {
std::vector<const BookmarkNode*> nodes;
BookmarkModel* model = browser_helper_.profile()->GetBookmarkModel();
model->GetNodesByURL(bb3_url_1_, &nodes);
if (nodes.size() == 0)
if (nodes.empty())
model->GetNodesByURL(bb3_url_2_, &nodes);
DCHECK(nodes.size());
bookmark_bb_3_ = nodes[0];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ InstallDialogContent2::InstallDialogContent2(
heading_->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
AddChildView(heading_);

if (permissions.size() == 0) {
if (permissions.empty()) {
right_column_width_ = kNoPermissionsRightColumnWidth;
} else {
right_column_width_ = kPermissionBoxWidth;
Expand Down
2 changes: 1 addition & 1 deletion chrome/common/extensions/update_manifest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ static bool ParseSingleAppTag(xmlNode* app_node, xmlNs* xml_namespace,
*error_detail = "Too many updatecheck tags on app (expecting only 1).";
return false;
}
if (updates.size() == 0) {
if (updates.empty()) {
*error_detail = "Missing updatecheck on app.";
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion chrome/common/unix_domain_socket_posix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ ssize_t UnixDomainSocket::SendRecvMsg(int fd,
}

if (result_fd) {
if (fd_vector.size() == 0) {
if (fd_vector.empty()) {
*result_fd = -1;
} else {
*result_fd = fd_vector[0];
Expand Down
2 changes: 1 addition & 1 deletion chrome/installer/util/delete_after_reboot_helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ void StringArrayToMultiSZBytes(const std::vector<PendingMove>& strings,
DCHECK(buffer);
buffer->clear();

if (strings.size() == 0) {
if (strings.empty()) {
// Leave buffer empty if we have no strings.
return;
}
Expand Down
2 changes: 1 addition & 1 deletion chrome/installer/util/shell_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ bool AnotherUserHasDefaultBrowser(BrowserDistribution* dist,
std::vector<std::wstring> v1, v2;
base::SplitString(registry_chrome_exe, L'\\', &v1);
base::SplitString(chrome_exe, L'\\', &v2);
if (v1.size() == 0 || v2.size() == 0 || v1.size() != v2.size())
if (v1.empty() || v2.empty() || v1.size() != v2.size())
return false;

// Now check that only one of the values within two '\' chars differ.
Expand Down
2 changes: 1 addition & 1 deletion chrome/tools/convert_dict/dic_reader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ bool PopulateWordSet(WordSet* word_set, FILE* file, AffReader* aff_reader,

std::vector<std::string> split;
SplitDicLine(line, &split);
if (split.size() == 0 || split.size() > 2) {
if (split.empty() || split.size() > 2) {
printf("Line %d has extra slashes in the %s file\n", line_number,
file_type);
return false;
Expand Down
2 changes: 1 addition & 1 deletion chrome_frame/policy_settings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ void PolicySettings::ReadContentTypeSetting(
sub_key += ASCIIToWide(policy::key::kChromeFrameContentTypes);

content_type_list->clear();
for (int i = 0; i < arraysize(kRootKeys) && content_type_list->size() == 0;
for (int i = 0; i < arraysize(kRootKeys) && content_type_list->empty();
++i) {
EnumerateKeyValues(kRootKeys[i], sub_key.c_str(), content_type_list);
}
Expand Down
2 changes: 1 addition & 1 deletion chrome_frame/urlmon_url_request.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1248,7 +1248,7 @@ void UrlmonUrlRequestManager::AddPrivacyDataForUrl(

bool fire_privacy_event = false;

if (privacy_info_.privacy_records.size() == 0)
if (privacy_info_.privacy_records.empty())
flags |= PRIVACY_URLISTOPLEVEL;

if (!privacy_info_.privacy_impacted) {
Expand Down
2 changes: 1 addition & 1 deletion content/browser/renderer_host/render_sandbox_host_linux.cc
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class SandboxIPCProcess {
<< "Sandbox host message is larger than kMaxFontFamilyLength";
return;
}
if (fds.size() == 0)
if (fds.empty())
return;

Pickle pickle(buf, len);
Expand Down
2 changes: 1 addition & 1 deletion content/browser/renderer_host/render_widget_host.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1239,7 +1239,7 @@ void RenderWidgetHost::AccessibilityNotificationsAck() {
}

void RenderWidgetHost::ProcessKeyboardEventAck(int type, bool processed) {
if (key_queue_.size() == 0) {
if (key_queue_.empty()) {
LOG(ERROR) << "Got a KeyEvent back from the renderer but we "
<< "don't seem to have sent it to the renderer!";
} else if (key_queue_.front().type != type) {
Expand Down
Loading

0 comments on commit f6b8ce3

Please sign in to comment.