← Back to team overview

linuxdcpp-team team mailing list archive

[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2855: change size() > 0 comparisons to empty()

 

------------------------------------------------------------
revno: 2855
committer: iceman50 <bdcdevel@xxxxxxxxx>
branch nick: dcplusplus
timestamp: Sat 2012-02-04 12:32:29 -0600
message:
  change size() > 0 comparisons to empty()
modified:
  dcpp/ADLSearch.cpp
  dcpp/AdcHub.cpp
  dcpp/ClientManager.cpp
  dcpp/ConnectionManager.cpp
  dcpp/NmdcHub.cpp
  dcpp/QueueManager.cpp
  dcpp/SimpleXML.h
  dwt/src/widgets/FolderDialog.cpp
  win32/DirectoryListingFrame.cpp
  win32/DirectoryListingFrame.h
  win32/HubFrame.cpp
  win32/QueueFrame.cpp
  win32/SearchFrame.cpp


--
lp:dcplusplus
https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk

Your team Dcplusplus-team is subscribed to branch lp:dcplusplus.
To unsubscribe from this branch go to https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk/+edit-subscription
=== modified file 'dcpp/ADLSearch.cpp'
--- dcpp/ADLSearch.cpp	2012-01-13 20:55:20 +0000
+++ dcpp/ADLSearch.cpp	2012-02-04 18:32:29 +0000
@@ -219,7 +219,7 @@
 					}
 
 					// Add search to collection
-					if(search.searchString.size() > 0) {
+					if(!search.searchString.empty()) {
 						collection.push_back(search);
 					}
 

=== modified file 'dcpp/AdcHub.cpp'
--- dcpp/AdcHub.cpp	2012-02-01 16:26:37 +0000
+++ dcpp/AdcHub.cpp	2012-02-04 18:32:29 +0000
@@ -519,7 +519,7 @@
 
 void AdcHub::handle(AdcCommand::GET, AdcCommand& c) noexcept {
 	if(c.getParameters().size() < 5) {
-		if(c.getParameters().size() > 0) {
+		if(!c.getParameters().empty()) {
 			if(c.getParam(0) == "blom") {
 				send(AdcCommand(AdcCommand::SEV_FATAL, AdcCommand::ERROR_PROTOCOL_GENERIC,
 					"Too few parameters for blom", AdcCommand::TYPE_HUB));
@@ -1024,7 +1024,7 @@
 
 	addParam(lastInfoMap, c, "SU", su);
 
-	if(c.getParameters().size() > 0) {
+	if(!c.getParameters().empty()) {
 		send(c);
 	}
 }

=== modified file 'dcpp/ClientManager.cpp'
--- dcpp/ClientManager.cpp	2012-01-13 20:55:20 +0000
+++ dcpp/ClientManager.cpp	2012-02-04 18:32:29 +0000
@@ -512,7 +512,7 @@
 				str += '|';
 			}
 
-			if(str.size() > 0)
+			if(!str.empty())
 				aClient->send(str);
 
 		} else {

=== modified file 'dcpp/ConnectionManager.cpp'
--- dcpp/ConnectionManager.cpp	2012-01-13 20:55:20 +0000
+++ dcpp/ConnectionManager.cpp	2012-02-04 18:32:29 +0000
@@ -434,7 +434,7 @@
 		return;
 	}
 
-	dcassert(aNick.size() > 0);
+	dcassert(!aNick.empty());
 	dcdebug("ConnectionManager::onMyNick %p, %s\n", (void*)aSource, aNick.c_str());
 	dcassert(!aSource->getUser());
 

=== modified file 'dcpp/NmdcHub.cpp'
--- dcpp/NmdcHub.cpp	2012-02-01 16:26:37 +0000
+++ dcpp/NmdcHub.cpp	2012-02-04 18:32:29 +0000
@@ -313,7 +313,7 @@
 		i = j + 1;
 		string terms = unescape(param.substr(i));
 
-		if(terms.size() > 0) {
+		if(!terms.empty()) {
 			if(seeker.compare(0, 4, "Hub:") == 0) {
 				OnlineUser* u = findUser(seeker.substr(4));
 
@@ -356,7 +356,7 @@
 
 		string tmpDesc = unescape(param.substr(i, j-i));
 		// Look for a tag...
-		if(tmpDesc.size() > 0 && tmpDesc[tmpDesc.size()-1] == '>') {
+		if(!tmpDesc.empty() && tmpDesc[tmpDesc.size()-1] == '>') {
 			x = tmpDesc.rfind('<');
 			if(x != string::npos) {
 				// Hm, we have something...disassemble it...

=== modified file 'dcpp/QueueManager.cpp'
--- dcpp/QueueManager.cpp	2012-02-04 15:43:31 +0000
+++ dcpp/QueueManager.cpp	2012-02-04 18:32:29 +0000
@@ -568,7 +568,7 @@
 		// This will be pretty slow on large queues...
 		if(BOOLSETTING(DONT_DL_ALREADY_QUEUED) && !(aFlags & QueueItem::FLAG_USER_LIST)) {
 			auto ql = fileQueue.find(root);
-			if (ql.size() > 0) {
+			if (!ql.empty()) {
 				// Found one or more existing queue items, lets see if we can add the source to them
 				bool sourceAdded = false;
 				for(auto i = ql.begin(); i != ql.end(); ++i) {

=== modified file 'dcpp/SimpleXML.h'
--- dcpp/SimpleXML.h	2012-02-04 15:43:31 +0000
+++ dcpp/SimpleXML.h	2012-02-04 18:32:29 +0000
@@ -123,7 +123,7 @@
 		checkChildSelected();
 		const string& tmp = getChildAttrib(aName);
 
-		return (tmp.size() > 0) && tmp[0] == '1';
+		return (!tmp.empty()) && tmp[0] == '1';
 	}
 
 	void fromXML(const string& aXML);

=== modified file 'dwt/src/widgets/FolderDialog.cpp'
--- dwt/src/widgets/FolderDialog.cpp	2012-01-13 20:55:20 +0000
+++ dwt/src/widgets/FolderDialog.cpp	2012-02-04 18:32:29 +0000
@@ -65,7 +65,7 @@
 		if ( ::SHGetPathFromIDList( lpIDL, buf ) ) {
 			folder = buf;
 
-			if(folder.size() > 0 && folder[folder.size()-1] != _T('\\')) {
+			if(!folder.empty() && folder[folder.size()-1] != _T('\\')) {
 				folder += _T('\\');
 			}
 

=== modified file 'win32/DirectoryListingFrame.cpp'
--- win32/DirectoryListingFrame.cpp	2012-01-23 20:18:58 +0000
+++ win32/DirectoryListingFrame.cpp	2012-02-04 18:32:29 +0000
@@ -786,7 +786,7 @@
 		}
 	}
 
-	if(WinUtil::lastDirs.size() > 0) {
+	if(!WinUtil::lastDirs.empty()) {
 		sub->appendSeparator();
 
 		for(i = 0; i < WinUtil::lastDirs.size(); ++i) {

=== modified file 'win32/DirectoryListingFrame.h'
--- win32/DirectoryListingFrame.h	2012-01-22 20:27:14 +0000
+++ win32/DirectoryListingFrame.h	2012-02-04 18:32:29 +0000
@@ -111,7 +111,7 @@
 		ItemInfo(DirectoryListing::File* f) : type(FILE), file(f) {
 			columns[COLUMN_FILENAME] = Text::toT(f->getName());
 			columns[COLUMN_TYPE] = Util::getFileExt(columns[COLUMN_FILENAME]);
-			if(columns[COLUMN_TYPE].size() > 0 && columns[COLUMN_TYPE][0] == '.')
+			if(!columns[COLUMN_TYPE].empty() && columns[COLUMN_TYPE][0] == '.')
 				columns[COLUMN_TYPE].erase(0, 1);
 
 			columns[COLUMN_EXACTSIZE] = Text::toT(Util::formatExactSize(f->getSize()));

=== modified file 'win32/HubFrame.cpp'
--- win32/HubFrame.cpp	2012-02-04 17:40:35 +0000
+++ win32/HubFrame.cpp	2012-02-04 18:32:29 +0000
@@ -605,7 +605,7 @@
 }
 
 void HubFrame::onGetPassword() {
-	if(client->getPassword().size() > 0) {
+	if(!client->getPassword().empty()) {
 		client->password(client->getPassword());
 		addStatus(T_("Stored password sent..."));
 	} else if(!waitingForPW) {
@@ -1014,7 +1014,7 @@
 		aEntry.setName(client->getHubName());
 		aEntry.setDescription(client->getHubDescription());
 		aEntry.setNick(client->getMyNick());
-		if(client->getPassword().size() > 0)  {
+		if(!client->getPassword().empty())  {
 			aEntry.setPassword(client->getPassword());
 		}
 		FavoriteManager::getInstance()->addFavorite(aEntry);

=== modified file 'win32/QueueFrame.cpp'
--- win32/QueueFrame.cpp	2012-01-29 19:25:56 +0000
+++ win32/QueueFrame.cpp	2012-02-04 18:32:29 +0000
@@ -296,7 +296,7 @@
 			tstring tmp;
 
 			for(auto j = getSources().begin(); j != getSources().end(); ++j) {
-				if(tmp.size() > 0)
+				if(!tmp.empty())
 					tmp += _T(", ");
 
 				if(j->getUser().user->isOnline())
@@ -359,7 +359,7 @@
 			tstring tmp;
 			for(auto j = getBadSources().begin(); j != getBadSources().end(); ++j) {
 				if(!j->isSet(QueueItem::Source::FLAG_REMOVED)) {
-					if(tmp.size() > 0)
+					if(!tmp.empty())
 						tmp += _T(", ");
 					tmp += WinUtil::getNicks(j->getUser());
 					tmp += _T(" (");
@@ -392,7 +392,7 @@
 		}
 		if(colMask & MASK_TYPE) {
 			display->columns[COLUMN_TYPE] = Text::toT(Util::getFileExt(getTarget()));
-			if(display->columns[COLUMN_TYPE].size() > 0 && display->columns[COLUMN_TYPE][0] == '.')
+			if(!display->columns[COLUMN_TYPE].empty() && display->columns[COLUMN_TYPE][0] == '.')
 				display->columns[COLUMN_TYPE].erase(0, 1);
 		}
 	}

=== modified file 'win32/SearchFrame.cpp'
--- win32/SearchFrame.cpp	2012-01-23 20:18:58 +0000
+++ win32/SearchFrame.cpp	2012-02-04 18:32:29 +0000
@@ -806,7 +806,7 @@
 	auto sub = menu->appendPopup(T_("Download to..."));
 
 	int n = 0;
-	if(favoriteDirs.size() > 0) {
+	if(!favoriteDirs.empty()) {
 		for(auto i = favoriteDirs.begin(); i != favoriteDirs.end(); ++i, ++n)
 			sub->appendItem(Text::toT(i->second), [=] { handleDownloadFavoriteDirs(n); });
 		sub->appendSeparator();
@@ -814,7 +814,7 @@
 
 	n = 0;
 	sub->appendItem(T_("&Browse..."), [this] { handleDownloadTo(); });
-	if(WinUtil::lastDirs.size() > 0) {
+	if(!WinUtil::lastDirs.empty()) {
 		sub->appendSeparator();
 		for(auto i = WinUtil::lastDirs.begin(); i != WinUtil::lastDirs.end(); ++i, ++n)
 			sub->appendItem(*i, [=] { handleDownloadTarget(n); });
@@ -822,7 +822,7 @@
 
 	if(checkTTH.hasTTH) {
 		targets = QueueManager::getInstance()->getTargets(checkTTH.tth);
-		if(targets.size() > 0) {
+		if(!targets.empty()) {
 			sub->appendSeparator();
 			for(auto i = targets.begin(); i != targets.end(); ++i, ++n)
 				sub->appendItem(Text::toT(*i), [=] { handleDownloadTarget(n); });
@@ -834,7 +834,7 @@
 	auto sub = menu->appendPopup(T_("Download whole directory to..."));
 
 	int n = 0;
-	if(favoriteDirs.size() > 0) {
+	if(!favoriteDirs.empty()) {
 		for(auto i = favoriteDirs.begin(); i != favoriteDirs.end(); ++i, ++n)
 			sub->appendItem(Text::toT(i->second), [=] { handleDownloadWholeFavoriteDirs(n); });
 		sub->appendSeparator();
@@ -842,7 +842,7 @@
 
 	n = 0;
 	sub->appendItem(T_("&Browse..."), [this] { handleDownloadDirTo(); });
-	if(WinUtil::lastDirs.size() > 0) {
+	if(!WinUtil::lastDirs.empty()) {
 		sub->appendSeparator();
 		for(auto i = WinUtil::lastDirs.begin(); i != WinUtil::lastDirs.end(); ++i, ++n)
 			sub->appendItem(*i, [=] { handleDownloadWholeTarget(n); });