Skip to content

Commit 746c017

Browse files
authored
refactor: Apply the readability-container-size-empty check with clang-tidy (#1957)
1 parent c5aa3cd commit 746c017

File tree

77 files changed

+133
-133
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+133
-133
lines changed

Core/GameEngine/Source/Common/Audio/AudioEventRTS.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ void AudioEventRTS::generateFilename( void )
329329
adjustForLocalization(m_filenameToLoad);
330330
return;
331331
} else {
332-
if (m_eventInfo->m_sounds.size() == 0) {
332+
if (m_eventInfo->m_sounds.empty()) {
333333
m_filenameToLoad = AsciiString::TheEmptyString;
334334
return;
335335
}

Core/GameEngine/Source/Common/System/Xfer.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ void Xfer::xferSTLObjectIDVector( std::vector<ObjectID> *objectIDVectorData )
395395
{
396396

397397
// sanity, the list should be empty before we transfer more data into it
398-
if( objectIDVectorData->size() != 0 )
398+
if( !objectIDVectorData->empty() )
399399
{
400400

401401
DEBUG_CRASH(( "Xfer::xferSTLObjectIDList - object vector should be empty before loading" ));
@@ -462,7 +462,7 @@ void Xfer::xferSTLObjectIDList( std::list< ObjectID > *objectIDListData )
462462
{
463463

464464
// sanity, the list should be empty before we transfer more data into it
465-
if( objectIDListData->size() != 0 )
465+
if( !objectIDListData->empty() )
466466
{
467467

468468
DEBUG_CRASH(( "Xfer::xferSTLObjectIDList - object list should be empty before loading" ));
@@ -528,7 +528,7 @@ void Xfer::xferSTLIntList( std::list< Int > *intListData )
528528
{
529529

530530
// sanity, the list should be empty before we transfer more data into it
531-
if( intListData->size() != 0 )
531+
if( !intListData->empty() )
532532
{
533533

534534
DEBUG_CRASH(( "Xfer::xferSTLIntList - int list should be empty before loading" ));

Core/GameEngine/Source/GameNetwork/GameSpy/LadderDefs.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ static LadderInfo *parseLadder(AsciiString raw)
163163
// end of a ladder
164164
if (lad->playersPerTeam >= 1 && lad->playersPerTeam <= MAX_SLOTS/2)
165165
{
166-
if (lad->validFactions.size() == 0)
166+
if (lad->validFactions.empty())
167167
{
168168
DEBUG_LOG(("No factions specified. Using all."));
169169
lad->validFactions.clear();
@@ -190,7 +190,7 @@ static LadderInfo *parseLadder(AsciiString raw)
190190
}
191191
}
192192

193-
if (lad->validMaps.size() == 0)
193+
if (lad->validMaps.empty())
194194
{
195195
DEBUG_LOG(("No maps specified. Using all."));
196196
std::list<AsciiString> qmMaps = TheGameSpyConfig->getQMMaps();
@@ -503,9 +503,9 @@ void LadderList::checkLadder( AsciiString fname, Int index )
503503
return;
504504
}
505505

506-
if (li->validMaps.size() == 0)
506+
if (li->validMaps.empty())
507507
{
508-
DEBUG_LOG(("Bailing because of li->validMaps.size() == 0"));
508+
DEBUG_LOG(("Bailing because of li->validMaps.empty()"));
509509
delete li;
510510
return;
511511
}

Core/GameEngine/Source/GameNetwork/GameSpy/MainMenuUtils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ static void startOnline( void )
191191
noPatchBeforeOnlineCallback);
192192
return;
193193
}
194-
if (queuedDownloads.size())
194+
if (!queuedDownloads.empty())
195195
{
196196
if (!hasWriteAccess())
197197
{

Core/GameEngine/Source/GameNetwork/GameSpy/PeerDefs.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ void GameSpyInfo::joinBestGroupRoom( void )
378378
return;
379379
}
380380

381-
if (m_groupRooms.size())
381+
if (!m_groupRooms.empty())
382382
{
383383
int minID = -1;
384384
int minPlayers = 1000;

Core/GameEngine/Source/GameNetwork/GameSpy/Thread/PeerThread.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1663,7 +1663,7 @@ void PeerThreadClass::Thread_Function()
16631663
m_playerFactions[i] = 0;
16641664
m_playerColors[i] = 0;
16651665
}
1666-
if (incomingRequest.password.length() > 0)
1666+
if (!incomingRequest.password.empty())
16671667
m_hasPassword = true;
16681668
else
16691669
m_hasPassword = false;
@@ -1714,7 +1714,7 @@ void PeerThreadClass::Thread_Function()
17141714

17151715
case PeerRequest::PEERREQUEST_UTMPLAYER:
17161716
{
1717-
if (incomingRequest.nick.length() > 0)
1717+
if (!incomingRequest.nick.empty())
17181718
{
17191719
peerUTMPlayer( peer, incomingRequest.nick.c_str(), incomingRequest.id.c_str(), incomingRequest.options.c_str(), PEERFalse );
17201720
}

Core/GameEngine/Source/GameNetwork/GameSpy/Thread/PersistentStorageThread.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,12 @@ static void debugDumpPlayerStats( const PSPlayerStats& stats )
102102
DEBUG_LOG(("gamesAsRandom: %d", stats.gamesAsRandom));
103103
}
104104

105-
if (stats.options.length())
105+
if (!stats.options.empty())
106106
{
107107
DEBUG_LOG(("Options: %s", stats.options.c_str()));
108108
}
109109

110-
if (stats.systemSpec.length())
110+
if (!stats.systemSpec.empty())
111111
{
112112
DEBUG_LOG(("systemSpec: %s", stats.systemSpec.c_str()));
113113
}
@@ -184,7 +184,7 @@ static void debugDumpPlayerStats( const PSPlayerStats& stats )
184184
DEBUG_LOG(("lastLadderPort: %d", stats.lastLadderPort));
185185
}
186186

187-
if (stats.lastLadderHost.length())
187+
if (!stats.lastLadderHost.empty())
188188
{
189189
DEBUG_LOG(("lastLadderHost: %s", stats.lastLadderHost.c_str()));
190190
}
@@ -246,12 +246,12 @@ void PSPlayerStats::incorporate( const PSPlayerStats& other )
246246
gamesAsRandom = other.gamesAsRandom;
247247
}
248248

249-
if (other.options.length())
249+
if (!other.options.empty())
250250
{
251251
options = other.options;
252252
}
253253

254-
if (other.systemSpec.length())
254+
if (!other.systemSpec.empty())
255255
{
256256
systemSpec = other.systemSpec;
257257
}
@@ -325,7 +325,7 @@ void PSPlayerStats::incorporate( const PSPlayerStats& other )
325325
{
326326
lastLadderPort = other.lastLadderPort;
327327
}
328-
if (other.lastLadderHost.length())
328+
if (!other.lastLadderHost.empty())
329329
{
330330
lastLadderHost = other.lastLadderHost;
331331
}
@@ -971,7 +971,7 @@ void PSThreadClass::Thread_Function()
971971
addedInDesyncs4 + req.addDesync, addedInDiscons4 + req.addDiscon));
972972
}
973973
pref.write();
974-
if (req.password.size() == 0)
974+
if (req.password.empty())
975975
return;
976976
}
977977
if (!req.player.id)
@@ -1370,13 +1370,13 @@ std::string GameSpyPSMessageQueueInterface::formatPlayerKVPairs( PSPlayerStats s
13701370
s.append(kvbuf);
13711371
}
13721372

1373-
if (stats.options.length())
1373+
if (!stats.options.empty())
13741374
{
13751375
snprintf(kvbuf, 256, "\\options\\%s", stats.options.c_str());
13761376
s.append(kvbuf);
13771377
}
13781378

1379-
if (stats.systemSpec.length())
1379+
if (!stats.systemSpec.empty())
13801380
{
13811381
snprintf(kvbuf, 256, "\\systemSpec\\%s", stats.systemSpec.c_str());
13821382
s.append(kvbuf);
@@ -1472,7 +1472,7 @@ std::string GameSpyPSMessageQueueInterface::formatPlayerKVPairs( PSPlayerStats s
14721472
sprintf(kvbuf, "\\ladderPort\\%d", stats.lastLadderPort);
14731473
s.append(kvbuf);
14741474
}
1475-
if (stats.lastLadderHost.length())
1475+
if (!stats.lastLadderHost.empty())
14761476
{
14771477
snprintf(kvbuf, 256, "\\ladderHost\\%s", stats.lastLadderHost.c_str());
14781478
s.append(kvbuf);

Core/GameEngineDevice/Source/StdDevice/Common/StdLocalFileSystem.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ Bool StdLocalFileSystem::createDirectory(AsciiString directory)
323323
std::replace(fixedDirectory.begin(), fixedDirectory.end(), '\\', '/');
324324
#endif
325325

326-
if ((fixedDirectory.length() > 0) && (fixedDirectory.length() < _MAX_DIR)) {
326+
if ((!fixedDirectory.empty()) && (fixedDirectory.length() < _MAX_DIR)) {
327327
// Convert to host path
328328
std::filesystem::path path(std::move(fixedDirectory));
329329

Core/Libraries/Source/WWVegas/WWLib/notifier.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ template<typename Event> class Observer
8888
//! Stop observing event
8989
void StopObserving()
9090
{
91-
while (mNotifiers.size() > 0)
91+
while (!mNotifiers.empty())
9292
{
9393
Notifier<Event>* notifier = mNotifiers.back();
9494
assert(notifier && "ERROR: NULL pointer in collection.");

Generals/Code/GameEngine/Include/GameClient/AnimateWindowManager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ namespace wnd
229229

230230
inline Bool AnimateWindowManager::isFinished( void ) { return !m_needsUpdate; };
231231
inline Bool AnimateWindowManager::isReversed( void ) { return m_reverse; };
232-
inline Bool AnimateWindowManager::isEmpty( void ){return (m_winList.size() == 0 && m_winMustFinishList.size() == 0); }
232+
inline Bool AnimateWindowManager::isEmpty( void ){return (m_winList.empty() && m_winMustFinishList.empty()); }
233233
//-----------------------------------------------------------------------------
234234
// EXTERNALS //////////////////////////////////////////////////////////////////
235235
//-----------------------------------------------------------------------------

0 commit comments

Comments
 (0)