Skip to content

Commit

Permalink
Plugin: replace calls to "<vector>.size() == 0" with "<vector>.empty()"
Browse files Browse the repository at this point in the history
(partly implements ref #58)
  • Loading branch information
hbeni committed Aug 30, 2021
1 parent 829b4ed commit f4b8a6c
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
12 changes: 6 additions & 6 deletions client/mumble-plugin/fgcom-mumble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ void fgcom_handlePTT() {
for (const auto &lcl_idty : fgcom_local_client) {
//int iid = lcl_idty.first;
fgcom_client lcl = lcl_idty.second;
if (lcl.radios.size() > 0) {
if (!lcl.radios.empty()) {
for (long unsigned int i=0; i<lcl.radios.size(); i++) {
radio_ptt = lcl.radios[i].ptt_req;

Expand Down Expand Up @@ -206,12 +206,12 @@ void fgcom_updateClientComment() {

// Add Identity and frequency information
fgcom_localcfg_mtx.lock();
if (fgcom_local_client.size() > 0) {
if (!fgcom_local_client.empty()) {
for (const auto &idty : fgcom_local_client) {
//int iid = idty.first;
fgcom_client lcl = idty.second;
std::string frqs;
if (lcl.radios.size() > 0) {
if (!lcl.radios.empty()) {
for (long unsigned int i=0; i<lcl.radios.size(); i++) {
if (lcl.radios[i].frequency != "") {
if (i >= 1) frqs += ", ";
Expand Down Expand Up @@ -463,7 +463,7 @@ mumble_error_t fgcom_initPlugin() {
}
}

if (fgcom_specialChannelID.size() == 0) {
if (fgcom_specialChannelID.empty()) {
pluginLog("ERROR: FAILED TO RETRIEVE SPECIAL CHANNEL '"+fgcom_cfg.specialChannel+"'! Please setup such an channel.");
mumAPI.log(ownPluginID, std::string("Failed to retrieve special channel '"+fgcom_cfg.specialChannel+"'! Please setup such an channel.").c_str());
}
Expand Down Expand Up @@ -825,7 +825,7 @@ void mumble_onUserTalkingStateChanged(mumble_connection_t connection, mumble_use
for (const auto &lcl_idty : fgcom_local_client) {
//int iid = lcl_idty.first;
fgcom_client lcl = lcl_idty.second;
if (lcl.radios.size() > 0) {
if (!lcl.radios.empty()) {
for (long unsigned int radio_id=0; radio_id<lcl.radios.size(); radio_id++) {
if (lcl.radios[radio_id].ptt_req) udp_protocol_ptt_detected = true;
}
Expand All @@ -838,7 +838,7 @@ void mumble_onUserTalkingStateChanged(mumble_connection_t connection, mumble_use
for (const auto &lcl_idty : fgcom_local_client) {
int iid = lcl_idty.first;
fgcom_client lcl = lcl_idty.second;
if (lcl.radios.size() > 0) {
if (!lcl.radios.empty()) {
for (long unsigned int radio_id=0; radio_id<lcl.radios.size(); radio_id++) {
bool radio_ptt_req = lcl.radios[radio_id].ptt_req; // requested from UDP state
auto radio_mapmumbleptt_srch = fgcom_cfg.mapMumblePTT.find(radio_id);
Expand Down
4 changes: 2 additions & 2 deletions client/mumble-plugin/fgcom-mumble.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@

// Plugin Version
#define FGCOM_VERSION_MAJOR 0
#define FGCOM_VERSION_MINOR 14
#define FGCOM_VERSION_PATCH 3
#define FGCOM_VERSION_MINOR 15
#define FGCOM_VERSION_PATCH 0

/*
* Is the plugin currently active?
Expand Down
4 changes: 2 additions & 2 deletions client/mumble-plugin/lib/debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void debug_out_internal_state() {
state_str += lcl_prefix + "lastUpdate="+lastUpdate_str_f+"\n";

state_str += lcl_prefix + std::to_string(lcl.radios.size()) + " radios registered\n";
if (lcl.radios.size() > 0) {
if (!lcl.radios.empty()) {
for (unsigned long int i=0; i<lcl.radios.size(); i++) {
state_str += " Radio "+std::to_string(i)+": frequency='"+lcl.radios[i].frequency+"'\n";
state_str += " Radio "+std::to_string(i)+": dialedFRQ='"+lcl.radios[i].dialedFRQ+"'\n";
Expand Down Expand Up @@ -90,7 +90,7 @@ void debug_out_internal_state() {
state_str += rmt_prefix + "lastNotify="+lastNotify_str_f+"\n";

state_str += rmt_prefix + std::to_string(rmt.radios.size()) + " radios registered\n";
if (rmt.radios.size() > 0) {
if (!rmt.radios.empty()) {
for (unsigned long int i=0; i<rmt.radios.size(); i++) {
state_str += " Radio "+std::to_string(i)+": frequency='"+rmt.radios[i].frequency+"'\n";
state_str += " Radio "+std::to_string(i)+": dialedFRQ='"+rmt.radios[i].dialedFRQ+"'\n";
Expand Down
4 changes: 2 additions & 2 deletions client/mumble-plugin/lib/garbage_collector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ void fgcom_gc_clean_lcl() {
fgcom_localcfg_mtx.unlock();

// update client comment if we removed identities
if (staleIIDs.size() > 0) fgcom_updateClientComment();
if (!staleIIDs.empty()) fgcom_updateClientComment();

}

Expand Down Expand Up @@ -109,7 +109,7 @@ void fgcom_gc_clean_rmt() {
}

// if the remote has no identities left: clear also the remote as such
if (fgcom_remote_clients.size() == 0) {
if (fgcom_remote_clients.empty()) {
staleRemoteClients.push_back(clid);
}

Expand Down
2 changes: 1 addition & 1 deletion client/mumble-plugin/lib/io_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ void notifyRemotes(int iid, FGCOM_NOTIFY_T what, int selector, mumble_userid_t t
fgcom_client lcl; // resolved local identity
if (what != NTFY_ASK) {
// skip notification attempts if we don't have any local state yet
if (fgcom_local_client.size() == 0 ) {
if (fgcom_local_client.empty()) {
pluginDbg("[mum_pluginIO] notifyRemotes(): no local state yet, skipping notifications.");
return;
}
Expand Down

0 comments on commit f4b8a6c

Please sign in to comment.