From 37f84b737243e3889671e5c389480ab1ff6afb9a Mon Sep 17 00:00:00 2001 From: Rubidium Date: Fri, 20 Oct 2023 20:22:49 +0200 Subject: [PATCH] Codechange: replace x.size() != 0 with !x.empty() --- src/autoreplace_gui.cpp | 2 +- src/depot_gui.cpp | 2 +- src/gfx_layout_icu.cpp | 2 +- src/group_gui.cpp | 2 +- src/network/core/udp.cpp | 2 +- src/network/network_chat_gui.cpp | 2 +- src/newgrf.cpp | 2 +- src/newgrf_gui.cpp | 2 +- src/string.cpp | 2 +- src/vehicle_gui.cpp | 2 +- src/viewport.cpp | 4 ++-- 11 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/autoreplace_gui.cpp b/src/autoreplace_gui.cpp index 086d77caeb..b358def3c8 100644 --- a/src/autoreplace_gui.cpp +++ b/src/autoreplace_gui.cpp @@ -222,7 +222,7 @@ class ReplaceVehicleWindow : public Window { /* We need to rebuild the left engines list */ this->GenerateReplaceVehList(true); this->vscroll[0]->SetCount(this->engines[0].size()); - if (this->reset_sel_engine && this->sel_engine[0] == INVALID_ENGINE && this->engines[0].size() != 0) { + if (this->reset_sel_engine && this->sel_engine[0] == INVALID_ENGINE && !this->engines[0].empty()) { this->sel_engine[0] = this->engines[0][0].engine_id; } } diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp index 5e9913ace4..32ad8d9143 100644 --- a/src/depot_gui.cpp +++ b/src/depot_gui.cpp @@ -810,7 +810,7 @@ struct DepotWindow : Window { case WID_D_SELL_ALL: /* Only open the confirmation window if there are anything to sell */ - if (this->vehicle_list.size() != 0 || this->wagon_list.size() != 0) { + if (!this->vehicle_list.empty() || !this->wagon_list.empty()) { SetDParam(0, this->type); SetDParam(1, this->GetDepotIndex()); ShowQuery( diff --git a/src/gfx_layout_icu.cpp b/src/gfx_layout_icu.cpp index 0996b64988..bd93842b8a 100644 --- a/src/gfx_layout_icu.cpp +++ b/src/gfx_layout_icu.cpp @@ -132,7 +132,7 @@ ICUParagraphLayout::ICUVisualRun::ICUVisualRun(const ICURun &run, int x) : glyphs(run.glyphs), glyph_to_char(run.glyph_to_char), total_advance(run.total_advance), font(run.font) { /* If there are no positions, the ICURun was not Shaped; that should never happen. */ - assert(run.positions.size() != 0); + assert(!run.positions.empty()); this->positions.reserve(run.positions.size()); /* "positions" is an array of x/y. So we need to alternate. */ diff --git a/src/group_gui.cpp b/src/group_gui.cpp index 55a47efe58..3f324dadf8 100644 --- a/src/group_gui.cpp +++ b/src/group_gui.cpp @@ -960,7 +960,7 @@ public: break; case WID_GL_MANAGE_VEHICLES_DROPDOWN: - assert(this->vehicles.size() != 0); + assert(!this->vehicles.empty()); switch (index) { case ADI_REPLACE: // Replace window diff --git a/src/network/core/udp.cpp b/src/network/core/udp.cpp index 09652225d8..2efb14e1dd 100644 --- a/src/network/core/udp.cpp +++ b/src/network/core/udp.cpp @@ -50,7 +50,7 @@ bool NetworkUDPSocketHandler::Listen() addr.Listen(SOCK_DGRAM, &this->sockets); } - return this->sockets.size() != 0; + return !this->sockets.empty(); } /** diff --git a/src/network/network_chat_gui.cpp b/src/network/network_chat_gui.cpp index a13236c8a0..5bbd6c80b4 100644 --- a/src/network/network_chat_gui.cpp +++ b/src/network/network_chat_gui.cpp @@ -67,7 +67,7 @@ static uint8_t *_chatmessage_backup = nullptr; ///< Backup in case text is moved */ static inline bool HaveChatMessages(bool show_all) { - if (show_all) return _chatmsg_list.size() != 0; + if (show_all) return !_chatmsg_list.empty(); auto now = std::chrono::steady_clock::now(); for (auto &cmsg : _chatmsg_list) { diff --git a/src/newgrf.cpp b/src/newgrf.cpp index 5154ff9ead..da7f9d5935 100644 --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -9069,7 +9069,7 @@ static void CalculateRefitMasks() /* Figure out which CTT to use for the default cargo, if it is 'first refittable'. */ const GRFFile *file = _gted[engine].defaultcargo_grf; if (file == nullptr) file = e->GetGRF(); - if (file != nullptr && file->grf_version >= 8 && file->cargo_list.size() != 0) { + if (file != nullptr && file->grf_version >= 8 && !file->cargo_list.empty()) { /* Use first refittable cargo from cargo translation table */ byte best_local_slot = UINT8_MAX; for (CargoID cargo_type : SetCargoBitIterator(ei->refit_mask)) { diff --git a/src/newgrf_gui.cpp b/src/newgrf_gui.cpp index 6d3c286570..f9e8e100d8 100644 --- a/src/newgrf_gui.cpp +++ b/src/newgrf_gui.cpp @@ -163,7 +163,7 @@ struct NewGRFParametersWindow : public Window { clicked_row(UINT_MAX), editable(editable) { - this->action14present = (c->num_valid_params != c->param.size() || c->param_info.size() != 0); + this->action14present = (c->num_valid_params != c->param.size() || !c->param_info.empty()); this->CreateNestedTree(); this->vscroll = this->GetScrollbar(WID_NP_SCROLLBAR); diff --git a/src/string.cpp b/src/string.cpp index badbe6bf63..7e8870b795 100644 --- a/src/string.cpp +++ b/src/string.cpp @@ -594,7 +594,7 @@ char *strcasestr(const char *haystack, const char *needle) */ static std::string_view SkipGarbage(std::string_view str) { - while (str.size() != 0 && (str[0] < '0' || IsInsideMM(str[0], ';', '@' + 1) || IsInsideMM(str[0], '[', '`' + 1) || IsInsideMM(str[0], '{', '~' + 1))) str.remove_prefix(1); + while (!str.empty() && (str[0] < '0' || IsInsideMM(str[0], ';', '@' + 1) || IsInsideMM(str[0], '[', '`' + 1) || IsInsideMM(str[0], '{', '~' + 1))) str.remove_prefix(1); return str; } diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp index 8b77f11c01..ced848932e 100644 --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -2080,7 +2080,7 @@ public: break; case WID_VL_MANAGE_VEHICLES_DROPDOWN: - assert(this->vehicles.size() != 0); + assert(!this->vehicles.empty()); switch (index) { case ADI_REPLACE: // Replace window diff --git a/src/viewport.cpp b/src/viewport.cpp index 02fd8796dd..0b77051ea9 100644 --- a/src/viewport.cpp +++ b/src/viewport.cpp @@ -1747,7 +1747,7 @@ void ViewportDoDraw(const Viewport *vp, int left, int top, int right, int bottom DrawTextEffects(&_vd.dpi); - if (_vd.tile_sprites_to_draw.size() != 0) ViewportDrawTileSprites(&_vd.tile_sprites_to_draw); + if (!_vd.tile_sprites_to_draw.empty()) ViewportDrawTileSprites(&_vd.tile_sprites_to_draw); for (auto &psd : _vd.parent_sprites_to_draw) { _vd.parent_sprites_to_sort.push_back(&psd); @@ -1773,7 +1773,7 @@ void ViewportDoDraw(const Viewport *vp, int left, int top, int right, int bottom vp->overlay->Draw(&dp); } - if (_vd.string_sprites_to_draw.size() != 0) { + if (!_vd.string_sprites_to_draw.empty()) { /* translate to world coordinates */ dp.left = UnScaleByZoom(_vd.dpi.left, zoom); dp.top = UnScaleByZoom(_vd.dpi.top, zoom);