Skip to content

Commit

Permalink
Codechange: replace x.size() != 0 with !x.empty()
Browse files Browse the repository at this point in the history
  • Loading branch information
rubidium42 committed Oct 20, 2023
1 parent ecf7dd3 commit ffe3166
Show file tree
Hide file tree
Showing 11 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/autoreplace_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/depot_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion src/gfx_layout_icu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down
2 changes: 1 addition & 1 deletion src/group_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -960,7 +960,7 @@ class VehicleGroupWindow : public BaseVehicleListWindow {
break;

case WID_GL_MANAGE_VEHICLES_DROPDOWN:
assert(this->vehicles.size() != 0);
assert(!this->vehicles.empty());

switch (index) {
case ADI_REPLACE: // Replace window
Expand Down
2 changes: 1 addition & 1 deletion src/network/core/udp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ bool NetworkUDPSocketHandler::Listen()
addr.Listen(SOCK_DGRAM, &this->sockets);
}

return this->sockets.size() != 0;
return !this->sockets.empty();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/network/network_chat_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/newgrf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
2 changes: 1 addition & 1 deletion src/newgrf_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/string.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion src/vehicle_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2080,7 +2080,7 @@ struct VehicleListWindow : public BaseVehicleListWindow {
break;

case WID_VL_MANAGE_VEHICLES_DROPDOWN:
assert(this->vehicles.size() != 0);
assert(!this->vehicles.empty());

switch (index) {
case ADI_REPLACE: // Replace window
Expand Down
4 changes: 2 additions & 2 deletions src/viewport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit ffe3166

Please sign in to comment.