Codechange: replace x.size() != 0 with !x.empty()

This commit is contained in:
Rubidium 2023-10-20 20:22:49 +02:00 committed by rubidium42
parent f16399f4c9
commit 37f84b7372
11 changed files with 12 additions and 12 deletions

View File

@ -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;
}
}

View File

@ -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(

View File

@ -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. */

View File

@ -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

View File

@ -50,7 +50,7 @@ bool NetworkUDPSocketHandler::Listen()
addr.Listen(SOCK_DGRAM, &this->sockets);
}
return this->sockets.size() != 0;
return !this->sockets.empty();
}
/**

View File

@ -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) {

View File

@ -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)) {

View File

@ -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);

View File

@ -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;
}

View File

@ -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

View File

@ -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);