Skip to content

Commit

Permalink
Use calls to empty() where appropriate.
Browse files Browse the repository at this point in the history
  • Loading branch information
tturocy committed Apr 8, 2023
1 parent 689c947 commit e49f735
Show file tree
Hide file tree
Showing 12 changed files with 22 additions and 22 deletions.
10 changes: 5 additions & 5 deletions src/games/nash.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ MixedStrategyDetailRenderer<T>::Render(const MixedStrategyProfile<T> &p_profile,
for (Array<GameStrategyRep *>::const_iterator
strategy = player->Strategies().begin();
strategy != player->Strategies().end(); ++strategy) {
if (strategy->GetLabel() != "") {
if (!strategy->GetLabel().empty()) {
m_stream << std::setw(8) << strategy->GetLabel() << " ";
}
else {
Expand Down Expand Up @@ -96,13 +96,13 @@ BehavStrategyDetailRenderer<T>::Render(const MixedBehaviorProfile<T> &p_profile,
for (int act = 1; act <= infoset->NumActions(); act++) {
GameAction action = infoset->GetAction(act);

if (infoset->GetLabel() != "") {
if (!infoset->GetLabel().empty()) {
m_stream << std::setw(7) << infoset->GetLabel() << " ";
}
else {
m_stream << std::setw(7) << infoset->GetNumber() << " ";
}
if (action->GetLabel() != "") {
if (!action->GetLabel().empty()) {
m_stream << std::setw(7) << action->GetLabel() << " ";
}
else {
Expand All @@ -129,13 +129,13 @@ BehavStrategyDetailRenderer<T>::Render(const MixedBehaviorProfile<T> &p_profile,

for (int n = 1; n <= infoset->NumMembers(); n++) {
GameNode node = infoset->GetMember(n);
if (infoset->GetLabel() != "") {
if (!infoset->GetLabel().empty()) {
m_stream << std::setw(7) << infoset->GetLabel() << " ";
}
else {
m_stream << std::setw(7) << infoset->GetNumber() << " ";
}
if (node->GetLabel() != "") {
if (!node->GetLabel().empty()) {
m_stream << std::setw(7) << node->GetLabel() << " ";
}
else {
Expand Down
2 changes: 1 addition & 1 deletion src/gui/dleditnode.cc
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ dialogEditNode::dialogEditNode(wxWindow *p_parent, Gambit::GameNode p_node)
for (int outc = 1; outc <= efg->NumOutcomes(); outc++) {
Gambit::GameOutcome outcome = efg->GetOutcome(outc);
std::string item = Gambit::lexical_cast<std::string>(outc) + ": " + outcome->GetLabel();
if (item == "") {
if (item.empty()) {
item = "Outcome" + Gambit::lexical_cast<std::string>(outc);
}

Expand Down
2 changes: 1 addition & 1 deletion src/gui/dlefgreveal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ gbtRevealMoveDialog::gbtRevealMoveDialog(wxWindow *p_parent,

for (int pl = 1; pl <= m_doc->NumPlayers(); pl++) {
Gambit::GamePlayer player = m_doc->GetGame()->GetPlayer(pl);
if (player->GetLabel() != "") {
if (player->GetLabel().empty()) {
m_players.push_back(new wxCheckBox(this, wxID_ANY,
wxString(player->GetLabel().c_str(),
*wxConvCurrent)));
Expand Down
2 changes: 1 addition & 1 deletion src/gui/dlnashmon.cc
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ void gbtNashMonitorDialog::OnEndProcess(wxProcessEvent &p_event)
wxString msg;
msg << tis.ReadLine();

if (msg != wxT("")) {
if (!msg.empty()) {
m_doc->DoAddOutput(*m_output, msg);
m_countText->SetLabel(wxString::Format(wxT("Number of equilibria found so far: %d"), m_output->NumProfiles()));
}
Expand Down
4 changes: 2 additions & 2 deletions src/gui/gameframe.cc
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ void gbtGameFrame::OnUpdate()
std::string gameTitle;
gameTitle = m_doc->GetGame()->GetTitle();

if (m_doc->GetFilename() != wxT("")) {
if (!m_doc->GetFilename().empty()) {
SetTitle(wxT("Gambit - [") + m_doc->GetFilename() +
wxT("] ") +
wxString(gameTitle.c_str(), *wxConvCurrent));
Expand Down Expand Up @@ -842,7 +842,7 @@ void gbtGameFrame::OnFileClose(wxCommandEvent &)

void gbtGameFrame::OnFileSave(wxCommandEvent &p_event)
{
if (p_event.GetId() == wxID_SAVEAS || m_doc->GetFilename() == wxT("")) {
if (p_event.GetId() == wxID_SAVEAS || m_doc->GetFilename().empty()) {
wxFileDialog dialog(this, _("Choose file"),
wxPathOnly(m_doc->GetFilename()),
wxFileNameFromPath(m_doc->GetFilename()),
Expand Down
2 changes: 1 addition & 1 deletion src/solvers/enummixed/enummixed.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ using namespace Gambit::linalg;
template <class T> List<List<MixedStrategyProfile<T> > >
EnumMixedStrategySolution<T>::GetCliques() const
{
if (m_cliques1.size() == 0) {
if (m_cliques1.empty()) {
// Cliques are generated on demand
int n = m_node1.Length();
if (m_node2.Length() != n) throw DimensionException();
Expand Down
10 changes: 5 additions & 5 deletions src/solvers/gtracer/aggame.cc
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,9 @@ void aggame::payoffMatrix(cmatrix &dest, cvector &s, agg::AggNumber fuzz){


//compute partial prob distributions
if (tasks.size()==0 && spares.size()==0) continue; //nothing to be done for this row
if (tasks.empty() && spares.empty()) continue; //nothing to be done for this row

if(aggPtr->isPure[currNode]||tasks.size()==0){
if(aggPtr->isPure[currNode]||tasks.empty()){
computePartialP_PureNode(rown, act1,tasks);
}else{//do bisection
computePartialP_bisect(rown,act1,tasks.begin(),tasks.end(),aggPtr->Pr[rown]);
Expand Down Expand Up @@ -258,7 +258,7 @@ void aggame::payoffMatrix(cmatrix &dest, cvector &s, agg::AggNumber fuzz){
}
else {
for(p=tasks.begin();p!=tasks.end();++p){
if(aggPtr->Pr[*p].size()==0){
if(aggPtr->Pr[*p].empty()){
std::cerr<<"AGG::payoffMatrix() ERROR for rown="
<<rown<<" act1="<<act1<<" *p=" <<*p
<<": the distribution should not be empty!"<<std::endl;
Expand All @@ -275,7 +275,7 @@ void aggame::payoffMatrix(cmatrix &dest, cvector &s, agg::AggNumber fuzz){
//if spares not empty, we need to compute nondisturbed payoffs
//which requires the distrib induced by everyone (except rown).
//we store this distrib in Pr[rown][act1][rown]
if (spares.size()>0){
if (!spares.empty()){
//assert(tasks.size()>0);
aggPtr->Pr[rown].reset();
aggPtr->Pr[rown].multiply(
Expand All @@ -296,7 +296,7 @@ void aggame::payoffMatrix(cmatrix &dest, cvector &s, agg::AggNumber fuzz){
agg::AggNumber undisturbedPayoff;
bool hasUndisturbed=false;

if(spares.size()>0){//for players in spares, we compute one undisturbed payoff
if(!spares.empty()){//for players in spares, we compute one undisturbed payoff
computeUndisturbedPayoff(undisturbedPayoff,hasUndisturbed,rown,act1, rown);
for(p=spares.begin();p!=spares.end();++p)
for(act2=0;act2<aggPtr->actions[*p];act2++)
Expand Down
2 changes: 1 addition & 1 deletion src/tools/enumpoly/gpoly.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ template<> double gPoly<double>::String_Coeff(double nega)
charnum++;
GetChar();
}
if (Coeff == "") return (nega);
if (Coeff.empty()) return nega;
else return (nega * strtod(Coeff.c_str(), nullptr));
}

Expand Down
2 changes: 1 addition & 1 deletion src/tools/gt/nfggnm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ int main(int argc, char *argv[])
NashGNMStrategySolver solver(renderer, verbose);

List<MixedStrategyProfile<double> > perts;
if (startFile != "") {
if (!startFile.empty()) {
std::ifstream startPerts(startFile.c_str());
perts = ReadStrategyPerturbations(game, startPerts);
}
Expand Down
4 changes: 2 additions & 2 deletions src/tools/liap/liap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ int main(int argc, char *argv[])
Game game = ReadGame(*input_stream);
if (!game->IsTree() || useStrategic) {
List<MixedStrategyProfile<double> > starts;
if (startFile != "") {
if (!startFile.empty()) {
std::ifstream startPoints(startFile.c_str());
starts = ReadStrategyProfiles(game, startPoints);
}
Expand All @@ -224,7 +224,7 @@ int main(int argc, char *argv[])
}
else {
List<MixedBehaviorProfile<double> > starts;
if (startFile != "") {
if (!startFile.empty()) {
std::ifstream startPoints(startFile.c_str());
starts = ReadBehaviorProfiles(game, startPoints);
}
Expand Down
2 changes: 1 addition & 1 deletion src/tools/logit/logit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ int main(int argc, char *argv[])
throw UndefinedException("Computing equilibria of games with imperfect recall is not supported.");
}

if (mleFile != "" && (!game->IsTree() || useStrategic)) {
if (!mleFile.empty() && (!game->IsTree() || useStrategic)) {
MixedStrategyProfile<double> frequencies(game->NewMixedStrategyProfile(0.0));
std::ifstream mleData(mleFile.c_str());
ReadProfile(mleData, frequencies);
Expand Down
2 changes: 1 addition & 1 deletion src/tools/simpdiv/nfgsimpdiv.cc
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ int main(int argc, char *argv[])
try {
Game game = ReadGame(*input_stream);
List<MixedStrategyProfile<Rational> > starts;
if (startFile != "") {
if (!startFile.empty()) {
std::ifstream startPoints(startFile.c_str());
starts = ReadProfiles(game, startPoints);
}
Expand Down

0 comments on commit e49f735

Please sign in to comment.