1
0
Fork 0

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

pull/11316/head
Rubidium 2023-10-20 20:18:31 +02:00 committed by rubidium42
parent c9276c2959
commit f16399f4c9
15 changed files with 23 additions and 23 deletions

View File

@ -763,7 +763,7 @@ static SQInteger closure_getinfos(HSQUIRRELVM v) {
res->NewSlot(SQString::Create(_ss(v),"name",-1),nc->_name); res->NewSlot(SQString::Create(_ss(v),"name",-1),nc->_name);
res->NewSlot(SQString::Create(_ss(v),"paramscheck",-1),nc->_nparamscheck); res->NewSlot(SQString::Create(_ss(v),"paramscheck",-1),nc->_nparamscheck);
SQObjectPtr typecheck; SQObjectPtr typecheck;
if(nc->_typecheck.size() > 0) { if(!nc->_typecheck.empty()) {
typecheck = typecheck =
SQArray::Create(_ss(v), nc->_typecheck.size()); SQArray::Create(_ss(v), nc->_typecheck.size());
for(SQUnsignedInteger n = 0; n<nc->_typecheck.size(); n++) { for(SQUnsignedInteger n = 0; n<nc->_typecheck.size(); n++) {

View File

@ -564,7 +564,7 @@ void SQFuncState::PopChildState()
SQFuncState::~SQFuncState() SQFuncState::~SQFuncState()
{ {
while(_childstates.size() > 0) while(!_childstates.empty())
{ {
PopChildState(); PopChildState();
} }

View File

@ -1008,7 +1008,7 @@ public:
this->groups.ForceRebuild(); this->groups.ForceRebuild();
this->BuildGroupList((CompanyID)this->window_number); this->BuildGroupList((CompanyID)this->window_number);
if (this->groups.size() > 0) { if (!this->groups.empty()) {
this->sel = this->groups[0]->index; this->sel = this->groups[0]->index;
} }
} }
@ -1095,7 +1095,7 @@ public:
if (!Group::IsValidID(this->sel)) { if (!Group::IsValidID(this->sel)) {
this->sel = INVALID_GROUP; this->sel = INVALID_GROUP;
if (this->groups.size() > 0) this->sel = this->groups[0]->index; if (!this->groups.empty()) this->sel = this->groups[0]->index;
} }
this->SetDirty(); this->SetDirty();

View File

@ -139,7 +139,7 @@ void DumpTarget::BeginStruct(size_t type_id, const std::string &name, const void
{ {
/* make composite name */ /* make composite name */
std::string cur_name = GetCurrentStructName(); std::string cur_name = GetCurrentStructName();
if (cur_name.size() > 0) { if (!cur_name.empty()) {
/* add name delimiter (we use structured names) */ /* add name delimiter (we use structured names) */
cur_name += "."; cur_name += ".";
} }

View File

@ -939,14 +939,14 @@ static const char *LoadDefaultDLSFile(const char *user_dls)
/* Calculate download size for the instrument. */ /* Calculate download size for the instrument. */
size_t i_size = sizeof(DMUS_DOWNLOADINFO) + sizeof(DMUS_INSTRUMENT); size_t i_size = sizeof(DMUS_DOWNLOADINFO) + sizeof(DMUS_INSTRUMENT);
if (dls_file.instruments[i].articulators.size() > 0) { if (!dls_file.instruments[i].articulators.empty()) {
/* Articulations are stored as two chunks, one containing meta data and one with the actual articulation data. */ /* Articulations are stored as two chunks, one containing meta data and one with the actual articulation data. */
offsets += 2; offsets += 2;
i_size += sizeof(DMUS_ARTICULATION2) + sizeof(CONNECTIONLIST) + sizeof(CONNECTION) * dls_file.instruments[i].articulators.size(); i_size += sizeof(DMUS_ARTICULATION2) + sizeof(CONNECTIONLIST) + sizeof(CONNECTION) * dls_file.instruments[i].articulators.size();
} }
for (std::vector<DLSFile::DLSRegion>::iterator rgn = dls_file.instruments[i].regions.begin(); rgn != dls_file.instruments[i].regions.end(); rgn++) { for (std::vector<DLSFile::DLSRegion>::iterator rgn = dls_file.instruments[i].regions.begin(); rgn != dls_file.instruments[i].regions.end(); rgn++) {
if (rgn->articulators.size() > 0) { if (!rgn->articulators.empty()) {
offsets += 2; offsets += 2;
i_size += sizeof(DMUS_ARTICULATION2) + sizeof(CONNECTIONLIST) + sizeof(CONNECTION) * rgn->articulators.size(); i_size += sizeof(DMUS_ARTICULATION2) + sizeof(CONNECTIONLIST) + sizeof(CONNECTION) * rgn->articulators.size();
} }
@ -999,7 +999,7 @@ static const char *LoadDefaultDLSFile(const char *user_dls)
instrument = inst_data + 1; instrument = inst_data + 1;
/* Write global articulations. */ /* Write global articulations. */
if (dls_file.instruments[i].articulators.size() > 0) { if (!dls_file.instruments[i].articulators.empty()) {
inst_data->ulGlobalArtIdx = last_offset; inst_data->ulGlobalArtIdx = last_offset;
offset_table[last_offset++] = (char *)instrument - inst_base; offset_table[last_offset++] = (char *)instrument - inst_base;
offset_table[last_offset++] = (char *)instrument + sizeof(DMUS_ARTICULATION2) - inst_base; offset_table[last_offset++] = (char *)instrument + sizeof(DMUS_ARTICULATION2) - inst_base;
@ -1028,18 +1028,18 @@ static const char *LoadDefaultDLSFile(const char *user_dls)
/* The wave sample data will be taken from the region, if defined, otherwise from the wave itself. */ /* The wave sample data will be taken from the region, if defined, otherwise from the wave itself. */
if (rgn.wave_sample.cbSize != 0) { if (rgn.wave_sample.cbSize != 0) {
inst_region->WSMP = rgn.wave_sample; inst_region->WSMP = rgn.wave_sample;
if (rgn.wave_loops.size() > 0) MemCpyT(inst_region->WLOOP, &rgn.wave_loops.front(), rgn.wave_loops.size()); if (!rgn.wave_loops.empty()) MemCpyT(inst_region->WLOOP, &rgn.wave_loops.front(), rgn.wave_loops.size());
instrument = (char *)(inst_region + 1) - sizeof(DMUS_REGION::WLOOP) + sizeof(WLOOP) * rgn.wave_loops.size(); instrument = (char *)(inst_region + 1) - sizeof(DMUS_REGION::WLOOP) + sizeof(WLOOP) * rgn.wave_loops.size();
} else { } else {
inst_region->WSMP = rgn.wave_sample; inst_region->WSMP = rgn.wave_sample;
if (dls_file.waves[wave_id].wave_loops.size() > 0) MemCpyT(inst_region->WLOOP, &dls_file.waves[wave_id].wave_loops.front(), dls_file.waves[wave_id].wave_loops.size()); if (!dls_file.waves[wave_id].wave_loops.empty()) MemCpyT(inst_region->WLOOP, &dls_file.waves[wave_id].wave_loops.front(), dls_file.waves[wave_id].wave_loops.size());
instrument = (char *)(inst_region + 1) - sizeof(DMUS_REGION::WLOOP) + sizeof(WLOOP) * dls_file.waves[wave_id].wave_loops.size(); instrument = (char *)(inst_region + 1) - sizeof(DMUS_REGION::WLOOP) + sizeof(WLOOP) * dls_file.waves[wave_id].wave_loops.size();
} }
/* Write local articulator data. */ /* Write local articulator data. */
if (rgn.articulators.size() > 0) { if (!rgn.articulators.empty()) {
inst_region->ulRegionArtIdx = last_offset; inst_region->ulRegionArtIdx = last_offset;
offset_table[last_offset++] = (char *)instrument - inst_base; offset_table[last_offset++] = (char *)instrument - inst_base;
offset_table[last_offset++] = (char *)instrument + sizeof(DMUS_ARTICULATION2) - inst_base; offset_table[last_offset++] = (char *)instrument + sizeof(DMUS_ARTICULATION2) - inst_base;
@ -1168,7 +1168,7 @@ void MusicDriver_DMusic::Stop()
} }
/* Unloaded any instruments we loaded. */ /* Unloaded any instruments we loaded. */
if (_dls_downloads.size() > 0) { if (!_dls_downloads.empty()) {
IDirectMusicPortDownload *download_port = nullptr; IDirectMusicPortDownload *download_port = nullptr;
_port->QueryInterface(IID_IDirectMusicPortDownload, (LPVOID *)&download_port); _port->QueryInterface(IID_IDirectMusicPortDownload, (LPVOID *)&download_port);

View File

@ -87,7 +87,7 @@ public:
*/ */
bool IsValid() const bool IsValid() const
{ {
return this->buf.size() > 0; return !this->buf.empty();
} }
/** /**

View File

@ -824,7 +824,7 @@ public:
case WID_NCL_NAME: case WID_NCL_NAME:
if (this->content.SortType() == widget - WID_NCL_CHECKBOX) { if (this->content.SortType() == widget - WID_NCL_CHECKBOX) {
this->content.ToggleSortOrder(); this->content.ToggleSortOrder();
if (this->content.size() > 0) this->list_pos = (int)this->content.size() - this->list_pos - 1; if (!this->content.empty()) this->list_pos = (int)this->content.size() - this->list_pos - 1;
} else { } else {
this->content.SetSortType(widget - WID_NCL_CHECKBOX); this->content.SetSortType(widget - WID_NCL_CHECKBOX);
this->content.ForceResort(); this->content.ForceResort();

View File

@ -5240,7 +5240,7 @@ static void NewSpriteGroup(ByteReader *buf)
} }
group->default_group = GetGroupFromGroupID(setid, type, buf->ReadWord()); group->default_group = GetGroupFromGroupID(setid, type, buf->ReadWord());
group->error_group = ranges.size() > 0 ? ranges[0].group : group->default_group; group->error_group = ranges.empty() ? group->default_group : ranges[0].group;
/* nvar == 0 is a special case -- we turn our value into a callback result */ /* nvar == 0 is a special case -- we turn our value into a callback result */
group->calculated_result = ranges.empty(); group->calculated_result = ranges.empty();

View File

@ -86,7 +86,7 @@ CargoID GetCargoTranslation(uint8_t cargo, const GRFFile *grffile, bool usebit)
/* Other cases use (possibly translated) cargobits */ /* Other cases use (possibly translated) cargobits */
if (grffile->cargo_list.size() > 0) { if (!grffile->cargo_list.empty()) {
/* ...and the cargo is in bounds, then get the cargo ID for /* ...and the cargo is in bounds, then get the cargo ID for
* the label */ * the label */
if (cargo < grffile->cargo_list.size()) return GetCargoIDByLabel(grffile->cargo_list[cargo]); if (cargo < grffile->cargo_list.size()) return GetCargoIDByLabel(grffile->cargo_list[cargo]);

View File

@ -367,7 +367,7 @@ int MacOSStringCompare(std::string_view s1, std::string_view s2)
/* Query CoreText for word and cluster break information. */ /* Query CoreText for word and cluster break information. */
this->str_info.resize(utf16_to_utf8.size()); this->str_info.resize(utf16_to_utf8.size());
if (utf16_str.size() > 0) { if (!utf16_str.empty()) {
CFAutoRelease<CFStringRef> str(CFStringCreateWithCharactersNoCopy(kCFAllocatorDefault, &utf16_str[0], utf16_str.size(), kCFAllocatorNull)); CFAutoRelease<CFStringRef> str(CFStringCreateWithCharactersNoCopy(kCFAllocatorDefault, &utf16_str[0], utf16_str.size(), kCFAllocatorNull));
/* Get cluster breaks. */ /* Get cluster breaks. */

View File

@ -550,11 +550,11 @@ const int *UniscribeParagraphLayout::UniscribeVisualRun::GetGlyphToCharMap() con
/* Query Uniscribe for word and cluster break information. */ /* Query Uniscribe for word and cluster break information. */
this->str_info.resize(utf16_to_utf8.size()); this->str_info.resize(utf16_to_utf8.size());
if (utf16_str.size() > 0) { if (!utf16_str.empty()) {
/* Itemize string into language runs. */ /* Itemize string into language runs. */
std::vector<SCRIPT_ITEM> runs = UniscribeItemizeString(&utf16_str[0], (int32_t)utf16_str.size()); std::vector<SCRIPT_ITEM> runs = UniscribeItemizeString(&utf16_str[0], (int32_t)utf16_str.size());
for (std::vector<SCRIPT_ITEM>::const_iterator run = runs.begin(); runs.size() > 0 && run != runs.end() - 1; run++) { for (std::vector<SCRIPT_ITEM>::const_iterator run = runs.begin(); !runs.empty() && run != runs.end() - 1; run++) {
/* Get information on valid word and character break.s */ /* Get information on valid word and character break.s */
int len = (run + 1)->iCharPos - run->iCharPos; int len = (run + 1)->iCharPos - run->iCharPos;
std::vector<SCRIPT_LOGATTR> attr(len); std::vector<SCRIPT_LOGATTR> attr(len);

View File

@ -877,7 +877,7 @@ public:
if (!_story_page_pool.IsValidID(this->selected_page_id)) { if (!_story_page_pool.IsValidID(this->selected_page_id)) {
this->selected_page_id = INVALID_STORY_PAGE; this->selected_page_id = INVALID_STORY_PAGE;
} }
if (this->selected_page_id == INVALID_STORY_PAGE && this->story_pages.size() > 0) { if (this->selected_page_id == INVALID_STORY_PAGE && !this->story_pages.empty()) {
/* No page is selected, but there exist at least one available. /* No page is selected, but there exist at least one available.
* => Select first page. * => Select first page.
*/ */

View File

@ -476,7 +476,7 @@ byte GetBestFittingSubType(Vehicle *v_from, Vehicle *v_for, CargoID dest_cargo_t
byte ret_refit_cyc = 0; byte ret_refit_cyc = 0;
bool success = false; bool success = false;
if (subtypes.size() > 0) { if (!subtypes.empty()) {
/* Check whether any articulated part is refittable to 'dest_cargo_type' with a subtype listed in 'subtypes' */ /* Check whether any articulated part is refittable to 'dest_cargo_type' with a subtype listed in 'subtypes' */
for (Vehicle *v = v_for; v != nullptr; v = v->HasArticulatedPart() ? v->GetNextArticulatedPart() : nullptr) { for (Vehicle *v = v_for; v != nullptr; v = v->HasArticulatedPart() ? v->GetNextArticulatedPart() : nullptr) {
const Engine *e = v->GetEngine(); const Engine *e = v->GetEngine();

View File

@ -134,7 +134,7 @@ struct DropdownWindow : Window {
DropdownWindow(Window *parent, DropDownList &&list, int selected, int button, bool instant_close, const Point &position, const Dimension &size, Colours wi_colour, bool scroll) DropdownWindow(Window *parent, DropDownList &&list, int selected, int button, bool instant_close, const Point &position, const Dimension &size, Colours wi_colour, bool scroll)
: Window(&_dropdown_desc), list(std::move(list)) : Window(&_dropdown_desc), list(std::move(list))
{ {
assert(this->list.size() > 0); assert(!this->list.empty());
this->position = position; this->position = position;

View File

@ -29,7 +29,7 @@ static const int SLIDER_WIDTH = 3;
void DrawSliderWidget(Rect r, int min_value, int max_value, int value, const std::map<int, StringID> &labels) void DrawSliderWidget(Rect r, int min_value, int max_value, int value, const std::map<int, StringID> &labels)
{ {
/* Allow space for labels. We assume they are in the small font. */ /* Allow space for labels. We assume they are in the small font. */
if (labels.size() > 0) r.bottom -= FONT_HEIGHT_SMALL + WidgetDimensions::scaled.hsep_normal; if (!labels.empty()) r.bottom -= FONT_HEIGHT_SMALL + WidgetDimensions::scaled.hsep_normal;
max_value -= min_value; max_value -= min_value;