diff --git a/src/3rdparty/catch2/catch.hpp b/src/3rdparty/catch2/catch.hpp --- a/src/3rdparty/catch2/catch.hpp +++ b/src/3rdparty/catch2/catch.hpp @@ -5922,7 +5922,7 @@ namespace Catch { } void testCaseEnded(TestCaseStats const& testCaseStats) override { auto node = std::make_shared(testCaseStats); - assert(m_sectionStack.size() == 0); + assert(m_sectionStack.empty()); node->children.push_back(m_rootSection); m_testCases.push_back(node); m_rootSection.reset(); diff --git a/src/ai/ai_gui.cpp b/src/ai/ai_gui.cpp --- a/src/ai/ai_gui.cpp +++ b/src/ai/ai_gui.cpp @@ -280,7 +280,7 @@ struct AIConfigWindow : public Window { this->SetWidgetDisabledState(WID_AIC_DECREASE_INTERVAL, GetGameSettings().difficulty.competitors_interval == MIN_COMPETITORS_INTERVAL); this->SetWidgetDisabledState(WID_AIC_INCREASE_INTERVAL, GetGameSettings().difficulty.competitors_interval == MAX_COMPETITORS_INTERVAL); this->SetWidgetDisabledState(WID_AIC_CHANGE, this->selected_slot == INVALID_COMPANY); - this->SetWidgetDisabledState(WID_AIC_CONFIGURE, this->selected_slot == INVALID_COMPANY || AIConfig::GetConfig(this->selected_slot)->GetConfigList()->size() == 0); + this->SetWidgetDisabledState(WID_AIC_CONFIGURE, this->selected_slot == INVALID_COMPANY || AIConfig::GetConfig(this->selected_slot)->GetConfigList()->empty()); this->SetWidgetDisabledState(WID_AIC_MOVE_UP, this->selected_slot == INVALID_COMPANY || !IsEditable((CompanyID)(this->selected_slot - 1))); this->SetWidgetDisabledState(WID_AIC_MOVE_DOWN, this->selected_slot == INVALID_COMPANY || !IsEditable((CompanyID)(this->selected_slot + 1))); diff --git a/src/ai/ai_scanner.cpp b/src/ai/ai_scanner.cpp --- a/src/ai/ai_scanner.cpp +++ b/src/ai/ai_scanner.cpp @@ -94,7 +94,7 @@ AIInfo *AIScannerInfo::SelectRandomAI() AIInfo *AIScannerInfo::FindInfo(const std::string &name, int version, bool force_exact_match) { - if (this->info_list.size() == 0) return nullptr; + if (this->info_list.empty()) return nullptr; if (name.empty()) return nullptr; if (version == -1) { diff --git a/src/blitter/factory.hpp b/src/blitter/factory.hpp --- a/src/blitter/factory.hpp +++ b/src/blitter/factory.hpp @@ -120,7 +120,7 @@ public: #else const char *default_blitter = "8bpp-optimized"; #endif - if (GetBlitters().size() == 0) return nullptr; + if (GetBlitters().empty()) return nullptr; const char *bname = name.empty() ? default_blitter : name.c_str(); for (auto &it : GetBlitters()) { diff --git a/src/core/kdtree.hpp b/src/core/kdtree.hpp --- a/src/core/kdtree.hpp +++ b/src/core/kdtree.hpp @@ -53,7 +53,7 @@ class Kdtree { /** Create one new node in the tree, return its index in the pool */ size_t AddNode(const T &element) { - if (this->free_list.size() == 0) { + if (this->free_list.empty()) { this->nodes.emplace_back(element); return this->nodes.size() - 1; } else { diff --git a/src/core/pool_func.cpp b/src/core/pool_func.cpp --- a/src/core/pool_func.cpp +++ b/src/core/pool_func.cpp @@ -20,7 +20,7 @@ { PoolVector *pools = PoolBase::GetPools(); pools->erase(std::find(pools->begin(), pools->end(), this)); - if (pools->size() == 0) delete pools; + if (pools->empty()) delete pools; } /** diff --git a/src/core/span_type.hpp b/src/core/span_type.hpp --- a/src/core/span_type.hpp +++ b/src/core/span_type.hpp @@ -84,7 +84,7 @@ public: constexpr size_t size() const noexcept { return static_cast( last - first ); } constexpr std::ptrdiff_t ssize() const noexcept { return static_cast( last - first ); } - constexpr bool empty() const noexcept { return size() == 0; } + constexpr bool empty() const noexcept { return this->size() == 0; } constexpr iterator begin() const noexcept { return iterator(first); } constexpr iterator end() const noexcept { return iterator(last); } diff --git a/src/driver.cpp b/src/driver.cpp --- a/src/driver.cpp +++ b/src/driver.cpp @@ -109,7 +109,7 @@ void DriverFactoryBase::SelectDriver(con */ bool DriverFactoryBase::SelectDriverImpl(const std::string &name, Driver::Type type) { - if (GetDrivers().size() == 0) return false; + if (GetDrivers().empty()) return false; if (name.empty()) { /* Probe for this driver, but do not fall back to dedicated/null! */ diff --git a/src/game/game_scanner.cpp b/src/game/game_scanner.cpp --- a/src/game/game_scanner.cpp +++ b/src/game/game_scanner.cpp @@ -35,7 +35,7 @@ void GameScannerInfo::RegisterAPI(class GameInfo *GameScannerInfo::FindInfo(const std::string &name, int version, bool force_exact_match) { - if (this->info_list.size() == 0) return nullptr; + if (this->info_list.empty()) return nullptr; if (name.empty()) return nullptr; if (version == -1) { diff --git a/src/gfx.cpp b/src/gfx.cpp --- a/src/gfx.cpp +++ b/src/gfx.cpp @@ -658,7 +658,7 @@ int DrawString(int left, int right, int } Layouter layout(str, INT32_MAX, colour, fontsize); - if (layout.size() == 0) return 0; + if (layout.empty()) return 0; return DrawLayoutLine(*layout.front(), top, left, right, align, underline, true); } diff --git a/src/gfx_layout_fallback.cpp b/src/gfx_layout_fallback.cpp --- a/src/gfx_layout_fallback.cpp +++ b/src/gfx_layout_fallback.cpp @@ -155,7 +155,7 @@ int FallbackParagraphLayout::FallbackLin */ int FallbackParagraphLayout::FallbackLine::GetWidth() const { - if (this->size() == 0) return 0; + if (this->empty()) return 0; /* * The last X position of a run contains is the end of that run. @@ -293,7 +293,7 @@ std::unique_ptrbuffer++; } - if (l->size() == 0 || last_char - begin > 0) { + if (l->empty() || last_char - begin > 0) { int w = l->GetWidth(); l->emplace_back(iter->second, begin, last_char - begin, begin - this->buffer_begin, w); } diff --git a/src/gfx_layout_icu.cpp b/src/gfx_layout_icu.cpp --- a/src/gfx_layout_icu.cpp +++ b/src/gfx_layout_icu.cpp @@ -380,7 +380,7 @@ std::vector ItemizeStyle(std::ve runs = ItemizeScript(buff, length, runs); runs = ItemizeStyle(runs, font_mapping); - if (runs.size() == 0) return nullptr; + if (runs.empty()) return nullptr; for (auto &run : runs) { run.Shape(buff, length); diff --git a/src/group_gui.cpp b/src/group_gui.cpp --- a/src/group_gui.cpp +++ b/src/group_gui.cpp @@ -510,13 +510,13 @@ public: this->vscroll->SetCount(this->vehgroups.size()); /* The drop down menu is out, *but* it may not be used, retract it. */ - if (this->vehicles.size() == 0 && this->IsWidgetLowered(WID_GL_MANAGE_VEHICLES_DROPDOWN)) { + if (this->vehicles.empty() && this->IsWidgetLowered(WID_GL_MANAGE_VEHICLES_DROPDOWN)) { this->RaiseWidget(WID_GL_MANAGE_VEHICLES_DROPDOWN); this->CloseChildWindows(WC_DROPDOWN_MENU); } /* Disable all lists management button when the list is empty */ - this->SetWidgetsDisabledState(this->vehicles.size() == 0 || _local_company != this->vli.company, + this->SetWidgetsDisabledState(this->vehicles.empty() || _local_company != this->vli.company, WID_GL_STOP_ALL, WID_GL_START_ALL, WID_GL_MANAGE_VEHICLES_DROPDOWN); diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp --- a/src/industry_cmd.cpp +++ b/src/industry_cmd.cpp @@ -2683,7 +2683,7 @@ static void CanCargoServiceIndustry(Carg */ int WhoCanServiceIndustry(Industry *ind) { - if (ind->stations_near.size() == 0) return 0; // No stations found at all => nobody services + if (ind->stations_near.empty()) return 0; // No stations found at all => nobody services int result = 0; for (const Vehicle *v : Vehicle::Iterate()) { diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp --- a/src/industry_gui.cpp +++ b/src/industry_gui.cpp @@ -1670,7 +1670,7 @@ public: case WID_ID_INDUSTRY_LIST: { int n = 0; Rect ir = r.Shrink(WidgetDimensions::scaled.framerect); - if (this->industries.size() == 0) { + if (this->industries.empty()) { DrawString(ir, STR_INDUSTRY_DIRECTORY_NONE); break; } diff --git a/src/music/dmusic.cpp b/src/music/dmusic.cpp --- a/src/music/dmusic.cpp +++ b/src/music/dmusic.cpp @@ -873,7 +873,7 @@ static const char *LoadDefaultDLSFile(co } /* If we couldn't load the file from the registry, try again at the default install path of the GM DLS file. */ - if (dls_file.instruments.size() == 0) { + if (dls_file.instruments.empty()) { static const wchar_t *DLS_GM_FILE = L"%windir%\\System32\\drivers\\gm.dls"; wchar_t path[MAX_PATH]; ExpandEnvironmentStrings(DLS_GM_FILE, path, lengthof(path)); diff --git a/src/music/midifile.cpp b/src/music/midifile.cpp --- a/src/music/midifile.cpp +++ b/src/music/midifile.cpp @@ -347,7 +347,7 @@ static bool FixupMidiData(MidiFile &targ std::sort(target.tempos.begin(), target.tempos.end(), TicktimeAscending); std::sort(target.blocks.begin(), target.blocks.end(), TicktimeAscending); - if (target.tempos.size() == 0) { + if (target.tempos.empty()) { /* No tempo information, assume 120 bpm (500,000 microseconds per beat */ target.tempos.push_back(MidiFile::TempoChange(0, 500000)); } @@ -359,9 +359,9 @@ static bool FixupMidiData(MidiFile &targ uint32_t last_ticktime = 0; for (size_t i = 0; i < target.blocks.size(); i++) { MidiFile::DataBlock &block = target.blocks[i]; - if (block.data.size() == 0) { + if (block.data.empty()) { continue; - } else if (block.ticktime > last_ticktime || merged_blocks.size() == 0) { + } else if (block.ticktime > last_ticktime || merged_blocks.empty()) { merged_blocks.push_back(block); last_ticktime = block.ticktime; } else { diff --git a/src/network/core/tcp_connect.cpp b/src/network/core/tcp_connect.cpp --- a/src/network/core/tcp_connect.cpp +++ b/src/network/core/tcp_connect.cpp @@ -203,7 +203,7 @@ void TCPConnecter::OnResolved(addrinfo * } if (_debug_net_level >= 6) { - if (this->addresses.size() == 0) { + if (this->addresses.empty()) { Debug(net, 6, "{} did not resolve", this->connection_string); } else { Debug(net, 6, "{} resolved in:", this->connection_string); diff --git a/src/network/core/tcp_listen.h b/src/network/core/tcp_listen.h --- a/src/network/core/tcp_listen.h +++ b/src/network/core/tcp_listen.h @@ -142,7 +142,7 @@ public: */ static bool Listen(uint16_t port) { - assert(sockets.size() == 0); + assert(sockets.empty()); NetworkAddressList addresses; GetBindAddresses(&addresses, port); @@ -151,7 +151,7 @@ public: address.Listen(SOCK_STREAM, &sockets); } - if (sockets.size() == 0) { + if (sockets.empty()) { Debug(net, 0, "Could not start network: could not create listening socket"); ShowNetworkError(STR_NETWORK_ERROR_SERVER_START); return false; diff --git a/src/network/core/udp.cpp b/src/network/core/udp.cpp --- a/src/network/core/udp.cpp +++ b/src/network/core/udp.cpp @@ -73,7 +73,7 @@ void NetworkUDPSocketHandler::CloseSocke */ void NetworkUDPSocketHandler::SendPacket(Packet *p, NetworkAddress *recv, bool all, bool broadcast) { - if (this->sockets.size() == 0) this->Listen(); + if (this->sockets.empty()) this->Listen(); for (auto &s : this->sockets) { /* Make a local copy because if we resolve it we cannot diff --git a/src/network/network.cpp b/src/network/network.cpp --- a/src/network/network.cpp +++ b/src/network/network.cpp @@ -703,7 +703,7 @@ void GetBindAddresses(NetworkAddressList } /* No address, so bind to everything. */ - if (addresses->size() == 0) { + if (addresses->empty()) { addresses->emplace_back("", port); } } diff --git a/src/network/network_content_gui.cpp b/src/network/network_content_gui.cpp --- a/src/network/network_content_gui.cpp +++ b/src/network/network_content_gui.cpp @@ -899,7 +899,7 @@ public: } } - if (this->content.size() == 0) { + if (this->content.empty()) { if (this->UpdateFilterState()) { this->content.ForceRebuild(); this->InvalidateData(); diff --git a/src/newgrf.cpp b/src/newgrf.cpp --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -1192,7 +1192,7 @@ static ChangeInfoResult RailVehicleChang break; } - if (_cur.grffile->railtype_list.size() == 0) { + if (_cur.grffile->railtype_list.empty()) { /* Use traction type to select between normal and electrified * rail only when no translation list is in place. */ if (_gted[e->index].railtypelabel == RAILTYPE_RAIL_LABEL && engclass >= EC_ELECTRIC) _gted[e->index].railtypelabel = RAILTYPE_ELECTRIC_LABEL; @@ -5242,7 +5242,7 @@ static void NewSpriteGroup(ByteReader *b group->default_group = GetGroupFromGroupID(setid, type, buf->ReadWord()); group->error_group = ranges.size() > 0 ? ranges[0].group : group->default_group; /* nvar == 0 is a special case -- we turn our value into a callback result */ - group->calculated_result = ranges.size() == 0; + group->calculated_result = ranges.empty(); /* Sort ranges ascending. When ranges overlap, this may required clamping or splitting them */ std::vector bounds; @@ -5511,7 +5511,7 @@ static CargoID TranslateCargo(uint8_t fe if ((feature == GSF_STATIONS || feature == GSF_ROADSTOPS) && ctype == 0xFE) return CT_DEFAULT_NA; if (ctype == 0xFF) return CT_PURCHASE; - if (_cur.grffile->cargo_list.size() == 0) { + if (_cur.grffile->cargo_list.empty()) { /* No cargo table, so use bitnum values */ if (ctype >= 32) { GrfMsg(1, "TranslateCargo: Cargo bitnum {} out of range (max 31), skipping.", ctype); @@ -8855,7 +8855,7 @@ static void BuildCargoTranslationMap() for (const CargoSpec *cs : CargoSpec::Iterate()) { if (!cs->IsValid()) continue; - if (_cur.grffile->cargo_list.size() == 0) { + if (_cur.grffile->cargo_list.empty()) { /* Default translation table, so just a straight mapping to bitnum */ _cur.grffile->cargo_map[cs->Index()] = cs->bitnum; } else { diff --git a/src/newgrf_gui.cpp b/src/newgrf_gui.cpp --- a/src/newgrf_gui.cpp +++ b/src/newgrf_gui.cpp @@ -1578,7 +1578,7 @@ void ShowMissingContentWindow(const GRFC ci->md5sum = HasBit(c->flags, GCF_COMPATIBLE) ? c->original_md5sum : c->ident.md5sum; cv.push_back(ci); } - ShowNetworkContentListWindow(cv.size() == 0 ? nullptr : &cv, CONTENT_TYPE_NEWGRF); + ShowNetworkContentListWindow(cv.empty() ? nullptr : &cv, CONTENT_TYPE_NEWGRF); } Listing NewGRFWindow::last_sorting = {false, 0}; diff --git a/src/newgrf_railtype.cpp b/src/newgrf_railtype.cpp --- a/src/newgrf_railtype.cpp +++ b/src/newgrf_railtype.cpp @@ -140,7 +140,7 @@ SpriteID GetCustomSignalSprite(const Rai */ RailType GetRailTypeTranslation(uint8_t railtype, const GRFFile *grffile) { - if (grffile == nullptr || grffile->railtype_list.size() == 0) { + if (grffile == nullptr || grffile->railtype_list.empty()) { /* No railtype table present. Return railtype as-is (if valid), so it works for original railtypes. */ if (railtype >= RAILTYPE_END || GetRailTypeInfo(static_cast(railtype))->label == 0) return INVALID_RAILTYPE; @@ -163,7 +163,7 @@ RailType GetRailTypeTranslation(uint8_t uint8_t GetReverseRailTypeTranslation(RailType railtype, const GRFFile *grffile) { /* No rail type table present, return rail type as-is */ - if (grffile == nullptr || grffile->railtype_list.size() == 0) return railtype; + if (grffile == nullptr || grffile->railtype_list.empty()) return railtype; /* Look for a matching rail type label in the table */ RailTypeLabel label = GetRailTypeInfo(railtype)->label; diff --git a/src/newgrf_roadtype.cpp b/src/newgrf_roadtype.cpp --- a/src/newgrf_roadtype.cpp +++ b/src/newgrf_roadtype.cpp @@ -156,7 +156,7 @@ uint8_t GetReverseRoadTypeTranslation(Ro if (grffile == nullptr) return roadtype; const std::vector *list = RoadTypeIsRoad(roadtype) ? &grffile->roadtype_list : &grffile->tramtype_list; - if (list->size() == 0) return roadtype; + if (list->empty()) return roadtype; /* Look for a matching road type label in the table */ RoadTypeLabel label = GetRoadTypeInfo(roadtype)->label; diff --git a/src/os/macosx/string_osx.cpp b/src/os/macosx/string_osx.cpp --- a/src/os/macosx/string_osx.cpp +++ b/src/os/macosx/string_osx.cpp @@ -276,7 +276,7 @@ int CoreTextParagraphLayout::CoreTextLin */ int CoreTextParagraphLayout::CoreTextLine::GetWidth() const { - if (this->size() == 0) return 0; + if (this->empty()) return 0; int total_width = 0; for (const auto &run : *this) { diff --git a/src/os/windows/string_uniscribe.cpp b/src/os/windows/string_uniscribe.cpp --- a/src/os/windows/string_uniscribe.cpp +++ b/src/os/windows/string_uniscribe.cpp @@ -291,7 +291,7 @@ static std::vector Uniscrib /* Itemize text. */ std::vector items = UniscribeItemizeString(buff, length); - if (items.size() == 0) return nullptr; + if (items.empty()) return nullptr; /* Build ranges from the items and the font map. A range is a run of text * that is part of a single item and formatted using a single font style. */ diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp --- a/src/rail_gui.cpp +++ b/src/rail_gui.cpp @@ -2384,7 +2384,7 @@ DropDownList GetRailTypeDropDownList(boo } } - if (list.size() == 0) { + if (list.empty()) { /* Empty dropdowns are not allowed */ list.push_back(std::make_unique(STR_NONE, INVALID_RAILTYPE, true)); } diff --git a/src/road_gui.cpp b/src/road_gui.cpp --- a/src/road_gui.cpp +++ b/src/road_gui.cpp @@ -1845,7 +1845,7 @@ DropDownList GetRoadTypeDropDownList(Roa } } - if (list.size() == 0) { + if (list.empty()) { /* Empty dropdowns are not allowed */ list.push_back(std::make_unique(STR_NONE, INVALID_ROADTYPE, true)); } @@ -1885,7 +1885,7 @@ DropDownList GetScenRoadTypeDropDownList list.push_back(std::move(item)); } - if (list.size() == 0) { + if (list.empty()) { /* Empty dropdowns are not allowed */ list.push_back(std::make_unique(STR_NONE, -1, true)); } diff --git a/src/saveload/game_sl.cpp b/src/saveload/game_sl.cpp --- a/src/saveload/game_sl.cpp +++ b/src/saveload/game_sl.cpp @@ -172,7 +172,7 @@ struct GSTRChunkHandler : ChunkHandler { } /* If there were no strings in the savegame, set GameStrings to nullptr */ - if (_current_data->raw_strings.size() == 0) { + if (_current_data->raw_strings.empty()) { delete _current_data; _current_data = nullptr; return; diff --git a/src/saveload/linkgraph_sl.cpp b/src/saveload/linkgraph_sl.cpp --- a/src/saveload/linkgraph_sl.cpp +++ b/src/saveload/linkgraph_sl.cpp @@ -197,7 +197,7 @@ SaveLoadTable GetLinkGraphJobDesc() static SaveLoadAddrProc * const proc = [](void *b, size_t extra) -> void * { return const_cast(static_cast(reinterpret_cast(std::addressof(static_cast(b)->settings)) + extra)); }; /* Build the SaveLoad array on first call and don't touch it later on */ - if (saveloads.size() == 0) { + if (saveloads.empty()) { GetSaveLoadFromSettingTable(_linkgraph_settings, saveloads); for (auto &sl : saveloads) { diff --git a/src/script/squirrel.cpp b/src/script/squirrel.cpp --- a/src/script/squirrel.cpp +++ b/src/script/squirrel.cpp @@ -172,7 +172,7 @@ struct ScriptAllocator { ~ScriptAllocator() { #ifdef SCRIPT_DEBUG_ALLOCATIONS - assert(this->allocations.size() == 0); + assert(this->allocations.empty()); #endif } }; diff --git a/src/settings_table.cpp b/src/settings_table.cpp --- a/src/settings_table.cpp +++ b/src/settings_table.cpp @@ -309,7 +309,7 @@ static void DifficultyNoiseChange(int32_ static void MaxNoAIsChange(int32_t) { if (GetGameSettings().difficulty.max_no_competitors != 0 && - AI::GetInfoList()->size() == 0 && + AI::GetInfoList()->empty() && (!_networking || _network_server)) { ShowErrorMessage(STR_WARNING_NO_SUITABLE_AI, INVALID_STRING_ID, WL_CRITICAL); } diff --git a/src/station.cpp b/src/station.cpp --- a/src/station.cpp +++ b/src/station.cpp @@ -253,7 +253,7 @@ void Station::MarkTilesDirty(bool cargo_ /* Don't waste time updating if there are no custom station graphics * that might change. Even if there are custom graphics, they might * not change. Unfortunately we have no way of telling. */ - if (this->speclist.size() == 0) return; + if (this->speclist.empty()) return; } for (h = 0; h < train_station.h; h++) { diff --git a/src/story_gui.cpp b/src/story_gui.cpp --- a/src/story_gui.cpp +++ b/src/story_gui.cpp @@ -622,8 +622,8 @@ public: */ void UpdatePrevNextDisabledState() { - this->SetWidgetDisabledState(WID_SB_PREV_PAGE, story_pages.size() == 0 || this->IsFirstPageSelected()); - this->SetWidgetDisabledState(WID_SB_NEXT_PAGE, story_pages.size() == 0 || this->IsLastPageSelected()); + this->SetWidgetDisabledState(WID_SB_PREV_PAGE, story_pages.empty() || this->IsFirstPageSelected()); + this->SetWidgetDisabledState(WID_SB_NEXT_PAGE, story_pages.empty() || this->IsLastPageSelected()); this->SetWidgetDirty(WID_SB_PREV_PAGE); this->SetWidgetDirty(WID_SB_NEXT_PAGE); } @@ -869,7 +869,7 @@ public: this->BuildStoryPageList(); /* Was the last page removed? */ - if (this->story_pages.size() == 0) { + if (this->story_pages.empty()) { this->selected_generic_title.clear(); } @@ -884,7 +884,7 @@ public: this->SetSelectedPage(this->story_pages[0]->index); } - this->SetWidgetDisabledState(WID_SB_SEL_PAGE, this->story_pages.size() == 0); + this->SetWidgetDisabledState(WID_SB_SEL_PAGE, this->story_pages.empty()); this->SetWidgetDirty(WID_SB_SEL_PAGE); this->UpdatePrevNextDisabledState(); } else if (data >= 0 && this->selected_page_id == data) { diff --git a/src/stringfilter_type.h b/src/stringfilter_type.h --- a/src/stringfilter_type.h +++ b/src/stringfilter_type.h @@ -56,7 +56,7 @@ public: * Check whether any filter words were entered. * @return true if no words were entered. */ - bool IsEmpty() const { return this->word_index.size() == 0; } + bool IsEmpty() const { return this->word_index.empty(); } void ResetState(); void AddLine(const char *str); diff --git a/src/strings.cpp b/src/strings.cpp --- a/src/strings.cpp +++ b/src/strings.cpp @@ -2044,7 +2044,7 @@ void InitializeLanguagePacks() for (Searchpath sp : _valid_searchpaths) { FillLanguageList(FioGetDirectory(sp, LANG_DIR)); } - if (_languages.size() == 0) UserError("No available language packs (invalid versions?)"); + if (_languages.empty()) UserError("No available language packs (invalid versions?)"); /* Acquire the locale of the current system */ const char *lang = GetCurrentLocale("LC_MESSAGES"); diff --git a/src/textfile_gui.cpp b/src/textfile_gui.cpp --- a/src/textfile_gui.cpp +++ b/src/textfile_gui.cpp @@ -122,7 +122,7 @@ uint TextfileWindow::ReflowContent() uint TextfileWindow::GetContentHeight() { - if (this->lines.size() == 0) return 0; + if (this->lines.empty()) return 0; return this->lines.back().bottom; } diff --git a/src/town_gui.cpp b/src/town_gui.cpp --- a/src/town_gui.cpp +++ b/src/town_gui.cpp @@ -823,7 +823,7 @@ public: case WID_TD_LIST: { int n = 0; Rect tr = r.Shrink(WidgetDimensions::scaled.framerect); - if (this->towns.size() == 0) { // No towns available. + if (this->towns.empty()) { // No towns available. DrawString(tr, STR_TOWN_DIRECTORY_NONE); break; } diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -854,7 +854,7 @@ static void MakeTrainBackup(TrainList &l static void RestoreTrainBackup(TrainList &list) { /* No train, nothing to do. */ - if (list.size() == 0) return; + if (list.empty()) return; Train *prev = nullptr; /* Iterate over the list and rebuild it. */ diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -349,7 +349,7 @@ void BaseVehicleListWindow::SetCargoFilt void BaseVehicleListWindow::FilterVehicleList() { this->vehgroups.Filter(this->cargo_filter[this->cargo_filter_criteria]); - if (this->vehicles.size() == 0) { + if (this->vehicles.empty()) { /* No vehicle passed through the filter, invalidate the previously selected vehicle */ this->vehicle_sel = INVALID_VEHICLE; } else if (this->vehicle_sel != INVALID_VEHICLE && std::find(this->vehicles.begin(), this->vehicles.end(), Vehicle::Get(this->vehicle_sel)) == this->vehicles.end()) { // previously selected engine didn't pass the filter, remove selection @@ -668,7 +668,7 @@ struct RefitWindow : public Window { if (!HasBit(cmask, cid)) continue; auto &list = this->refit_list[cid]; - bool first_vehicle = list.size() == 0; + bool first_vehicle = list.empty(); if (first_vehicle) { /* Keeping the current subtype is always an option. It also serves as the option in case of no subtypes */ list.push_back({cid, UINT8_MAX, STR_EMPTY}); @@ -1949,7 +1949,7 @@ public: this->BuildVehicleList(); this->SortVehicleList(); - if (this->vehicles.size() == 0 && this->IsWidgetLowered(WID_VL_MANAGE_VEHICLES_DROPDOWN)) { + if (this->vehicles.empty() && this->IsWidgetLowered(WID_VL_MANAGE_VEHICLES_DROPDOWN)) { this->CloseChildWindows(WC_DROPDOWN_MENU); } @@ -1963,7 +1963,7 @@ public: } if (this->owner == _local_company) { this->SetWidgetDisabledState(WID_VL_AVAILABLE_VEHICLES, this->vli.type != VL_STANDARD); - this->SetWidgetsDisabledState(this->vehicles.size() == 0, + this->SetWidgetsDisabledState(this->vehicles.empty(), WID_VL_MANAGE_VEHICLES_DROPDOWN, WID_VL_STOP_ALL, WID_VL_START_ALL);