diff --git a/examples/corelib/serialization/savegame/main.cpp b/examples/corelib/serialization/savegame/main.cpp index 408b08dbc91..f97b0d595f9 100644 --- a/examples/corelib/serialization/savegame/main.cpp +++ b/examples/corelib/serialization/savegame/main.cpp @@ -4,25 +4,28 @@ #include "game.h" #include +#include +#include #include +using namespace Qt::StringLiterals; // for _L1 + //! [0] int main(int argc, char *argv[]) { QCoreApplication app(argc, argv); - QStringList args = QCoreApplication::arguments(); - bool newGame = true; - if (args.length() > 1) - newGame = (args[1].toLower() != QStringLiteral("load")); - bool json = true; - if (args.length() > 2) - json = (args[2].toLower() != QStringLiteral("binary")); + + const QStringList args = QCoreApplication::arguments(); + const bool newGame + = args.size() <= 1 || QString::compare(args[1], "load"_L1, Qt::CaseInsensitive) == 0; + const bool json + = args.size() <= 2 || QString::compare(args[2], "binary"_L1, Qt::CaseInsensitive) == 0; Game game; if (newGame) game.newGame(); else if (!game.loadGame(json ? Game::Json : Game::Binary)) - return 1; + return 1; // Game is played; changes are made... //! [0] //! [1]