Replace size() method with empty() when possible.

There is no guaranteed that size() is a constant-time function.
This commit is contained in:
Haojian Wu 2017-03-30 21:44:15 +02:00
parent e4c571fc68
commit d18b34d55f
4 changed files with 5 additions and 6 deletions

View file

@ -54,7 +54,6 @@
#include "device/bluetooth/dbus/dbus_bluez_manager_wrapper_linux.h"
#endif
using content::BrowserThread;
namespace brightray {
@ -107,7 +106,7 @@ NOINLINE void WaitingForUIThreadToHandleIOError() {
}
int BrowserX11IOErrorHandler(Display* d) {
if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)) {
// Wait for the UI thread (which has a different connection to the X server)
// to get the error. We can't call shutdown from this thread without
// tripping an error. Doing it through a function so that we'll be able

View file

@ -205,7 +205,7 @@ vector<FilePath> Index::Search(string query) {
vector<FilePath> result;
FileIdsMap::const_iterator ids_it = file_ids_.begin();
for (; ids_it != file_ids_.end(); ++ids_it) {
if (trigrams.size() == 0 ||
if (trigrams.empty() ||
file_ids.find(ids_it->second) != file_ids.end()) {
result.push_back(ids_it->first);
}

View file

@ -67,7 +67,7 @@ DevToolsNetworkInterceptor*
DevToolsNetworkController::GetInterceptor(const std::string& client_id) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
if (!interceptors_.size() || client_id.empty())
if (interceptors_.empty() || client_id.empty())
return nullptr;
DevToolsNetworkInterceptor* interceptor = interceptors_.get(client_id);

View file

@ -108,7 +108,7 @@ uint64_t DevToolsNetworkInterceptor::UpdateThrottledRecords(
uint64_t last_tick,
base::TimeDelta tick_length) {
if (tick_length.is_zero()) {
DCHECK(!records->size());
DCHECK(records->empty());
return last_tick;
}
@ -195,7 +195,7 @@ base::TimeTicks DevToolsNetworkInterceptor::CalculateDesiredTime(
void DevToolsNetworkInterceptor::ArmTimer(base::TimeTicks now) {
size_t suspend_count = suspended_.size();
if (!download_.size() && !upload_.size() && !suspend_count) {
if (download_.empty() && upload_.empty() && !suspend_count) {
timer_.Stop();
return;
}