wsd: string::empty() is clearer than size() == 0
Change-Id: If2e25d344b5718c35cb9ae7b7519010ee88f0f60 Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>pull/5991/head
parent
268aed2f73
commit
9c39ebad1f
|
@ -531,7 +531,7 @@ bool ChildSession::_handleInput(const char *buffer, int length)
|
|||
}
|
||||
else if (tokens.equals(0, "sallogoverride"))
|
||||
{
|
||||
if (tokens.size() == 0 || tokens.equals(1, "default"))
|
||||
if (tokens.empty() || tokens.equals(1, "default"))
|
||||
{
|
||||
getLOKit()->setOption("sallogoverride", nullptr);
|
||||
}
|
||||
|
@ -1081,9 +1081,10 @@ bool ChildSession::downloadAs(const StringVector& tokens)
|
|||
const std::string url = jailDoc + urlToSend;
|
||||
const std::string urlAnonym = jailDoc + tmpDir + '/' + Poco::Path(nameAnonym).getFileName();
|
||||
|
||||
LOG_DBG("Calling LOK's saveAs with: url='" << urlAnonym << "', format='" <<
|
||||
(format.empty() ? "(nullptr)" : format.c_str()) << "', ' filterOptions=" <<
|
||||
(filterOptions.empty() ? "(nullptr)" : filterOptions.c_str()) << "'.");
|
||||
LOG_DBG("Calling LOK's saveAs with URL: ["
|
||||
<< urlAnonym << "], Format: [" << (format.empty() ? "(nullptr)" : format.c_str())
|
||||
<< "], Filter Options: ["
|
||||
<< (filterOptions.empty() ? "(nullptr)" : filterOptions.c_str()) << ']');
|
||||
|
||||
bool success = getLOKitDocument()->saveAs(url.c_str(),
|
||||
format.empty() ? nullptr : format.c_str(),
|
||||
|
@ -2405,7 +2406,7 @@ bool ChildSession::saveAs(const StringVector& tokens)
|
|||
std::vector<std::string> pathSegments;
|
||||
wopiURL.getPathSegments(pathSegments);
|
||||
|
||||
if (pathSegments.size() == 0)
|
||||
if (pathSegments.empty())
|
||||
{
|
||||
sendTextFrameAndLogError("error: cmd=saveas kind=syntax");
|
||||
return false;
|
||||
|
@ -2490,9 +2491,9 @@ bool ChildSession::saveAs(const StringVector& tokens)
|
|||
<< "], Filter Options: ["
|
||||
<< (filterOptions.empty() ? "(nullptr)" : filterOptions.c_str()) << ']');
|
||||
|
||||
success = getLOKitDocument()->saveAs(encodedURL.c_str(),
|
||||
format.size() == 0 ? nullptr :format.c_str(),
|
||||
filterOptions.size() == 0 ? nullptr : filterOptions.c_str());
|
||||
success = getLOKitDocument()->saveAs(
|
||||
encodedURL.c_str(), format.empty() ? nullptr : format.c_str(),
|
||||
filterOptions.empty() ? nullptr : filterOptions.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2521,7 +2522,7 @@ bool ChildSession::exportAs(const StringVector& tokens)
|
|||
std::vector<std::string> pathSegments;
|
||||
wopiURL.getPathSegments(pathSegments);
|
||||
|
||||
if (pathSegments.size() == 0)
|
||||
if (pathSegments.empty())
|
||||
{
|
||||
sendTextFrameAndLogError("error: cmd=exportas kind=syntax");
|
||||
return false;
|
||||
|
|
|
@ -404,7 +404,7 @@ class DeltaGenerator {
|
|||
}
|
||||
}
|
||||
LOG_TRC("Created delta of size " << output.size());
|
||||
if (output.size() == 0)
|
||||
if (output.empty())
|
||||
{
|
||||
// The tile content is identical to what the client already has, so skip it
|
||||
LOG_TRC("Identical / un-changed tile");
|
||||
|
|
|
@ -2010,7 +2010,7 @@ static void flushTraceEventRecordings()
|
|||
{
|
||||
std::vector<std::string> &r = traceEventRecords[n];
|
||||
|
||||
if (r.size() == 0)
|
||||
if (r.empty())
|
||||
return;
|
||||
|
||||
std::size_t totalLength = 0;
|
||||
|
@ -2501,7 +2501,7 @@ int pollCallback(void* pData, int timeoutUs)
|
|||
v.push_back(p);
|
||||
}
|
||||
lock.unlock();
|
||||
if (v.size() == 0)
|
||||
if (v.empty())
|
||||
{
|
||||
std::this_thread::sleep_for(std::chrono::microseconds(timeoutUs));
|
||||
}
|
||||
|
@ -2526,7 +2526,7 @@ void wakeCallback(void* pData)
|
|||
return reinterpret_cast<KitSocketPoll*>(pData)->wakeup();
|
||||
#else
|
||||
std::unique_lock<std::mutex> lock(KitSocketPoll::KSPollsMutex);
|
||||
if (KitSocketPoll::KSPolls.size() == 0)
|
||||
if (KitSocketPoll::KSPolls.empty())
|
||||
return;
|
||||
|
||||
std::vector<std::shared_ptr<KitSocketPoll>> v;
|
||||
|
|
|
@ -38,7 +38,7 @@ class DelaySocket : public Socket {
|
|||
_sendTime = std::chrono::steady_clock::now() +
|
||||
std::chrono::milliseconds(delayMs);
|
||||
}
|
||||
bool isError() { return _data.size() == 0; }
|
||||
bool isError() const { return _data.empty(); }
|
||||
std::chrono::steady_clock::time_point getSendTime() const { return _sendTime; }
|
||||
std::vector<char>& getData() { return _data; }
|
||||
private:
|
||||
|
@ -156,7 +156,7 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
if (_chunks.size() == 0)
|
||||
if (_chunks.empty())
|
||||
{
|
||||
if (_state == EofFlushWrites)
|
||||
changeState(Closed);
|
||||
|
@ -167,7 +167,7 @@ public:
|
|||
if (std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||
now - chunk->getSendTime()).count() >= 0)
|
||||
{
|
||||
if (chunk->getData().size() == 0)
|
||||
if (chunk->getData().empty())
|
||||
{ // delayed error or close
|
||||
DELAY_LOG('#' << getFD() << " handling delayed close\n");
|
||||
changeState(Closed);
|
||||
|
@ -203,7 +203,7 @@ public:
|
|||
if (len > 0)
|
||||
chunk->getData().erase(chunk->getData().begin(), chunk->getData().begin() + len);
|
||||
|
||||
if (chunk->getData().size() == 0)
|
||||
if (chunk->getData().empty())
|
||||
_chunks.erase(_chunks.begin(), _chunks.begin() + 1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -566,7 +566,7 @@ ssize_t fakeSocketRead(int fd, void *buf, size_t nbytes)
|
|||
// If peer is closed or shut down, we continue to be readable
|
||||
if (pair.fd[N] == -1 || pair.shutdown[N])
|
||||
pair.readable[K] = true;
|
||||
else if (pair.buffer[K].size() == 0)
|
||||
else if (pair.buffer[K].empty())
|
||||
pair.readable[K] = false;
|
||||
|
||||
FAKESOCKET_LOG(2, "FakeSocket Read from #" << fd << " got " << result << (result == 1 ? " byte" : " bytes") << flush());
|
||||
|
|
|
@ -1192,7 +1192,7 @@ public:
|
|||
len = readData(buf.data(), available);
|
||||
assert(len == available);
|
||||
_bytesRecvd += len;
|
||||
assert(_inBuffer.size() == 0);
|
||||
assert(_inBuffer.empty());
|
||||
_inBuffer.append(buf.data(), len);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -192,7 +192,7 @@ void DeltaTests::testDeltaSequence()
|
|||
reinterpret_cast<unsigned char *>(&text[0]),
|
||||
0, 0, width, height, width, height,
|
||||
TileLocation(1, 2, 3, 0, 1), delta, textWid, false) == false);
|
||||
LOK_ASSERT(delta.size() == 0);
|
||||
LOK_ASSERT(delta.empty());
|
||||
|
||||
// Build a delta between text2 & textWid
|
||||
LOK_ASSERT(gen.createDelta(
|
||||
|
|
|
@ -87,7 +87,7 @@ protected:
|
|||
|
||||
StringVector tokens(StringVector::tokenize(line, ' '));
|
||||
|
||||
if (tokens.size() == 0)
|
||||
if (tokens.empty())
|
||||
continue;
|
||||
|
||||
if (tokens.equals(0, "?") || tokens.equals(0, "help"))
|
||||
|
|
|
@ -63,7 +63,7 @@ void Stress::printHelp()
|
|||
|
||||
int Stress::main(const std::vector<std::string>& args)
|
||||
{
|
||||
if (args.size() == 0)
|
||||
if (args.empty())
|
||||
{
|
||||
printHelp();
|
||||
return EX_NOINPUT;
|
||||
|
|
|
@ -1030,7 +1030,7 @@ void Admin::startMonitors()
|
|||
|
||||
void Admin::updateMonitors(std::vector<std::string>& oldMonitors)
|
||||
{
|
||||
if (oldMonitors.size() == 0)
|
||||
if (oldMonitors.empty())
|
||||
{
|
||||
startMonitors();
|
||||
return;
|
||||
|
|
|
@ -417,7 +417,7 @@ void cleanupDocBrokers()
|
|||
}
|
||||
|
||||
#if !MOBILEAPP && ENABLE_DEBUG
|
||||
if (COOLWSD::SingleKit && DocBrokers.size() == 0)
|
||||
if (COOLWSD::SingleKit && DocBrokers.empty())
|
||||
{
|
||||
LOG_DBG("Setting ShutdownRequestFlag: No more docs left in single-kit mode.");
|
||||
SigUtil::requestShutdown();
|
||||
|
|
|
@ -300,7 +300,7 @@ std::unique_ptr<LocalStorage::LocalFileInfo> LocalStorage::getLocalFileInfo()
|
|||
if (user_name != nullptr)
|
||||
userNameString = std::string(user_name);
|
||||
#endif
|
||||
if (userNameString.size() == 0)
|
||||
if (userNameString.empty())
|
||||
userNameString = "LocalUser#" + userId;
|
||||
|
||||
return std::unique_ptr<LocalStorage::LocalFileInfo>(
|
||||
|
|
Loading…
Reference in New Issue