Ticket #5773: libs_libmythdb-krazy2-single-char-operations.patch

File libs_libmythdb-krazy2-single-char-operations.patch, 14.0 KB (added by Erik Hovland <erik@…>, 16 years ago)

Uses single char instead of single value string

  • mythtv/libs/libmythdb/httpcomms.cpp

    It is more efficient to use single char operations with single
    
    From: Erik Hovland <erik@hovland.org>
    
    quotes instead of strings (double quotes).
    ---
    
     mythtv/libs/libmythdb/httpcomms.cpp   |    4 ++--
     mythtv/libs/libmythdb/lcddevice.cpp   |   32 ++++++++++++++++----------------
     mythtv/libs/libmythdb/mythdb.cpp      |   18 +++++++++---------
     mythtv/libs/libmythdb/mythdbcon.cpp   |    6 +++---
     mythtv/libs/libmythdb/mythdirs.cpp    |    4 ++--
     mythtv/libs/libmythdb/mythstorage.cpp |   10 +++++-----
     mythtv/libs/libmythdb/mythverbose.cpp |    6 +++---
     mythtv/libs/libmythdb/oldsettings.cpp |    4 ++--
     8 files changed, 42 insertions(+), 42 deletions(-)
    
    diff --git a/mythtv/libs/libmythdb/httpcomms.cpp b/mythtv/libs/libmythdb/httpcomms.cpp
    index a5a7047..5901c3e 100644
    a b void HttpComms::request(QUrl &url, int timeoutms, bool allowGzip) 
    7070    QString path = url.path();
    7171
    7272    if (url.hasQuery())
    73         path += "?" + url.encodedQuery();
     73        path += '?' + url.encodedQuery();
    7474
    7575    QHttpRequestHeader header("GET", path);
    7676    QString userAgent = "Mozilla/9.876 (X11; U; Linux 2.2.12-20 i686, en) "
    void HttpComms::headerReceived(const QHttpResponseHeader &resp) 
    240240            }
    241241            else
    242242            {
    243                 QString sUser(m_webCredentials.user + ":" + m_webCredentials.pass);
     243                QString sUser(m_webCredentials.user + ':' + m_webCredentials.pass);
    244244                QByteArray auth = QCodecs::base64Encode(sUser.toLocal8Bit());
    245245                m_curRequest.setValue( "Authorization", QString( "Basic " ).append( auth ) );
    246246            }
  • mythtv/libs/libmythdb/lcddevice.cpp

    diff --git a/mythtv/libs/libmythdb/lcddevice.cpp b/mythtv/libs/libmythdb/lcddevice.cpp
    index 7509e1b..8b36602 100644
    a b void LCD::sendToServer(const QString &someText) 
    226226        // Buffer this up in the hope that the connection will open soon
    227227
    228228        send_buffer += someText;
    229         send_buffer += "\n";
     229        send_buffer += '\n';
    230230    }
    231231}
    232232
    void LCD::readyRead(MythSocket *sock) 
    272272        VERBOSE(VB_NETWORK|VB_EXTRA, QString(LOC + "Received from server: %1")
    273273                .arg(lineFromServer));
    274274
    275     aList = lineFromServer.split(" ");
     275    aList = lineFromServer.split(' ');
    276276    if (aList[0] == "CONNECTED")
    277277    {
    278278        // We got "CONNECTED", which is a response to "HELLO"
    void LCD::setMusicProgress(QString time, float value) 
    413413        return;
    414414
    415415    value = min(max(0.0f, value), 1.0f);
    416     sendToServer("SET_MUSIC_PROGRESS " + quotedString(time) + " " +
     416    sendToServer("SET_MUSIC_PROGRESS " + quotedString(time) + ' ' +
    417417            QString().setNum(value));   
    418418}
    419419
    void LCD::switchToMusic(const QString &artist, const QString &album, const QStri 
    485485
    486486    VERBOSE(VB_IMPORTANT|VB_EXTRA, LOC + "switchToMusic");
    487487
    488     sendToServer("SWITCH_TO_MUSIC " + quotedString(artist) + " "
    489             + quotedString(album) + " "
     488    sendToServer("SWITCH_TO_MUSIC " + quotedString(artist) + ' '
     489            + quotedString(album) + ' '
    490490            + quotedString(track));
    491491}
    492492
    void LCD::switchToChannel(QString channum, QString title, QString subtitle) 
    497497
    498498    VERBOSE(VB_IMPORTANT|VB_EXTRA, LOC + "switchToChannel");
    499499
    500     sendToServer("SWITCH_TO_CHANNEL " + quotedString(channum) + " "
    501             + quotedString(title) + " "
     500    sendToServer("SWITCH_TO_CHANNEL " + quotedString(channum) + ' '
     501            + quotedString(title) + ' '
    502502            + quotedString(subtitle));
    503503}
    504504
    void LCD::switchToMenu(QList<LCDMenuItem> &menuItems, QString app_name, 
    516516    QString s = "SWITCH_TO_MENU ";
    517517
    518518    s += quotedString(app_name);
    519     s += " " + QString(popMenu ? "TRUE" : "FALSE");
     519    s += ' ' + QString(popMenu ? "TRUE" : "FALSE");
    520520
    521521
    522522    QListIterator<LCDMenuItem> it(menuItems);
    void LCD::switchToMenu(QList<LCDMenuItem> &menuItems, QString app_name, 
    525525    while (it.hasNext())
    526526    {
    527527        curItem = &(it.next());
    528         s += " " + quotedString(curItem->ItemName());
     528        s += ' ' + quotedString(curItem->ItemName());
    529529
    530530        if (curItem->isChecked() == CHECKED)
    531531            s += " CHECKED";   
    void LCD::switchToMenu(QList<LCDMenuItem> &menuItems, QString app_name, 
    534534        else if (curItem->isChecked() == NOTCHECKABLE)
    535535            s += " NOTCHECKABLE";
    536536
    537         s += " " + QString(curItem->isSelected() ? "TRUE" : "FALSE");
    538         s += " " + QString(curItem->Scroll() ? "TRUE" : "FALSE");
     537        s += ' ' + QString(curItem->isSelected() ? "TRUE" : "FALSE");
     538        s += ' ' + QString(curItem->Scroll() ? "TRUE" : "FALSE");
    539539        QString sIndent;
    540540        sIndent.setNum(curItem->getIndent());
    541         s += " " + sIndent;
     541        s += ' ' + sIndent;
    542542    }
    543543
    544544    sendToServer(s);
    void LCD::switchToGeneric(QList<LCDTextItem> &textItems) 
    565565
    566566        QString sRow;
    567567        sRow.setNum(curItem->getRow());
    568         s += " " + sRow;
     568        s += ' ' + sRow;
    569569
    570570        if (curItem->getAlignment() == ALIGN_LEFT)
    571571            s += " ALIGN_LEFT";   
    void LCD::switchToGeneric(QList<LCDTextItem> &textItems) 
    574574        else if (curItem->getAlignment() == ALIGN_CENTERED)
    575575            s += " ALIGN_CENTERED";
    576576
    577         s += " " + quotedString(curItem->getText());
    578         s += " " + quotedString(curItem->getScreen());
    579         s += " " + QString(curItem->getScroll() ? "TRUE" : "FALSE");
     577        s += ' ' + quotedString(curItem->getText());
     578        s += ' ' + quotedString(curItem->getScreen());
     579        s += ' ' + QString(curItem->getScroll() ? "TRUE" : "FALSE");
    580580    }
    581581
    582582    sendToServer(s);
  • mythtv/libs/libmythdb/mythdb.cpp

    diff --git a/mythtv/libs/libmythdb/mythdb.cpp b/mythtv/libs/libmythdb/mythdb.cpp
    index 8d91e87..8b9988d 100644
    a b QString MythDB::toCommaList(const QMap<QString, QVariant> &bindings, 
    104104    QString str = QString("%1").arg("", indent);
    105105    for (; it != bindings.end(); ++it)
    106106    {
    107         const QString curBinding = it.key() + "=" + (*it).toString() + ",";
     107        const QString curBinding = it.key() + '=' + (*it).toString() + ',';
    108108        if ((curColumn > indent) &&
    109109            ((curBinding.length() + curColumn) > maxColumn))
    110110        {
    111             str += "\n";
     111            str += '\n';
    112112            str += QString("%1").arg("", indent);
    113113            curColumn = indent;
    114114        }
    115115        if (curColumn > indent)
    116116        {
    117             str += " ";
     117            str += ' ';
    118118            curColumn++;
    119119        }
    120120        str += curBinding;
    121121        curColumn += curBinding.length();
    122122    }
    123123    str = str.left(str.length() - 1); // remove trailing comma.
    124     str += "\n";
     124    str += '\n';
    125125
    126126    return str;
    127127}
    void MythDB::DBError(const QString &where, const QSqlQuery& query) 
    131131    QString str = QString("DB Error (%1):\n").arg(where);
    132132
    133133    str += "Query was:\n";
    134     str += query.executedQuery() + "\n";
     134    str += query.executedQuery() + '\n';
    135135    QString tmp = toCommaList(query.boundValues());
    136136    if (!tmp.isEmpty())
    137137    {
    bool MythDB::SaveSettingOnHost(const QString &key, 
    210210    if (d->ignoreDatabase)
    211211    {
    212212        ClearSettingsCache(key, newValue);
    213         ClearSettingsCache(host + " " + key, newValue);
     213        ClearSettingsCache(host + ' ' + key, newValue);
    214214        return true;
    215215    }
    216216
    bool MythDB::SaveSettingOnHost(const QString &key, 
    268268    }
    269269
    270270    ClearSettingsCache(key, newValue);
    271     ClearSettingsCache(host + " " + key, newValue);
     271    ClearSettingsCache(host + ' ' + key, newValue);
    272272
    273273    return success;
    274274}
    QString MythDB::GetSettingOnHost(const QString &key, const QString &host, 
    373373{
    374374    bool found = false;
    375375    QString value = defaultval;
    376     QString myKey = host + " " + key;
     376    QString myKey = host + ' ' + key;
    377377
    378378    if (d->overriddenSettings.contains(myKey))
    379379    {
    QString MythDB::GetSettingOnHost(const QString &key, const QString &host, 
    430430    if (found && d->useSettingsCache)
    431431    {
    432432        d->settingsCacheLock.lock();
    433         d->settingsCache[host + " " + key] = value;
     433        d->settingsCache[host + ' ' + key] = value;
    434434        d->settingsCacheLock.unlock();
    435435    }
    436436
  • mythtv/libs/libmythdb/mythdbcon.cpp

    diff --git a/mythtv/libs/libmythdb/mythdbcon.cpp b/mythtv/libs/libmythdb/mythdbcon.cpp
    index 80bd7f6..a0c0bca 100644
    a b void MDBManager::CloseDatabases() 
    290290    {
    291291        db = *it;
    292292        VERBOSE(VB_IMPORTANT,
    293                 "Closing DB connection named '" + db->m_name + "'");
     293                "Closing DB connection named '" + db->m_name + '\'');
    294294        db->m_db.close();
    295295        ++it;
    296296    }
    bool MSqlQuery::exec() 
    420420        while (b.hasNext())
    421421        {
    422422            b.next();
    423             str.replace(b.key(), "'" + b.value().toString() + "'");
     423            str.replace(b.key(), '\'' + b.value().toString() + '\'');
    424424        }
    425425
    426         VERBOSE(VB_DATABASE, "MSqlQuery::exec() \"" + str + "\"");
     426        VERBOSE(VB_DATABASE, "MSqlQuery::exec() \"" + str + '"');
    427427    }
    428428
    429429    return result;
  • mythtv/libs/libmythdb/mythdirs.cpp

    diff --git a/mythtv/libs/libmythdb/mythdirs.cpp b/mythtv/libs/libmythdb/mythdirs.cpp
    index ffd4760..d6bbfcf 100644
    a b void InitializeMythDirs(void) 
    6060        confdir = QDir::homePath() + "/.mythtv";
    6161
    6262    sharedir = installprefix + "/share/mythtv/";
    63     libdir = installprefix + "/" + QString(LIBDIRNAME) + "/mythtv/";
     63    libdir = installprefix + '/' + QString(LIBDIRNAME) + "/mythtv/";
    6464    themedir = sharedir + "themes/";
    6565    pluginsdir = libdir + "plugins/";
    6666    translationsdir = sharedir + "i18n/";
    static const QString kPluginLibSuffix = ".so"; 
    9191
    9292QString GetPluginsNameFilter(void)
    9393{
    94     return kPluginLibPrefix + "*" + kPluginLibSuffix;
     94    return kPluginLibPrefix + '*' + kPluginLibSuffix;
    9595}
    9696
    9797QString FindPluginName(const QString &plugname)
  • mythtv/libs/libmythdb/mythstorage.cpp

    diff --git a/mythtv/libs/libmythdb/mythstorage.cpp b/mythtv/libs/libmythdb/mythstorage.cpp
    index 5a12cca..e4fccd2 100644
    a b void SimpleDBStorage::Load(void) 
    99    MSqlQuery query(MSqlQuery::InitCon());
    1010    MSqlBindings bindings;
    1111    query.prepare(
    12         "SELECT " + GetColumnName() + " "
    13         "FROM "   + GetTableName() + " " +
     12        "SELECT " + GetColumnName() + ' ' +
     13        "FROM "   + GetTableName() + ' ' +
    1414        "WHERE "  + GetWhereClause(bindings));
    1515    query.bindValues(bindings);
    1616
    void SimpleDBStorage::Save(QString _table) 
    3636
    3737    MSqlBindings bindings;
    3838    QString querystr = QString("SELECT * FROM " + _table + " WHERE "
    39                                + GetWhereClause(bindings) + ";");
     39                               + GetWhereClause(bindings) + ';');
    4040
    4141    MSqlQuery query(MSqlQuery::InitCon());
    4242    query.prepare(querystr);
    void SimpleDBStorage::Save(QString _table) 
    5555        MSqlBindings bindings;
    5656
    5757        querystr = QString("UPDATE " + _table + " SET " + GetSetClause(bindings) +
    58                            " WHERE " + GetWhereClause(bindings) + ";");
     58                           " WHERE " + GetWhereClause(bindings) + ';');
    5959
    6060        query.prepare(querystr);
    6161        query.bindValues(bindings);
    void SimpleDBStorage::Save(QString _table) 
    6969        MSqlBindings bindings;
    7070
    7171        querystr = QString("INSERT INTO " + _table + " SET "
    72                            + GetSetClause(bindings) + ";");
     72                           + GetSetClause(bindings) + ';');
    7373
    7474        query.prepare(querystr);
    7575        query.bindValues(bindings);
  • mythtv/libs/libmythdb/mythverbose.cpp

    diff --git a/mythtv/libs/libmythdb/mythverbose.cpp b/mythtv/libs/libmythdb/mythverbose.cpp
    index 50b3e2d..2cb6837 100644
    a b int parse_verbose_arg(QString arg) 
    1616    QString option;
    1717    bool reverseOption;
    1818
    19     if (arg.startsWith("-"))
     19    if (arg.startsWith('-'))
    2020    {
    2121        qDebug() << "Invalid or missing argument to -v/--verbose option\n";
    2222        return GENERIC_EXIT_INVALID_CMDLINE;
    int parse_verbose_arg(QString arg) 
    4040            {
    4141                QString m_verbose = verboseString;
    4242                m_verbose.replace(QRegExp(" "), ",");
    43                 m_verbose.replace(QRegExp("^,"), "");
     43                m_verbose.remove(QRegExp("^,"));
    4444                qDebug() <<
    4545                  "Verbose debug levels.\n" <<
    4646                  "Accepts any combination (separated by comma) of:\n\n" <<
    int parse_verbose_arg(QString arg) 
    8282                    if (ARG_ADDITIVE) \
    8383                    { \
    8484                        print_verbose_messages |= ARG_VALUE; \
    85                         verboseString = verboseString + " " + ARG_STR; \
     85                        verboseString = verboseString + ' ' + ARG_STR; \
    8686                    } \
    8787                    else \
    8888                    { \
  • mythtv/libs/libmythdb/oldsettings.cpp

    diff --git a/mythtv/libs/libmythdb/oldsettings.cpp b/mythtv/libs/libmythdb/oldsettings.cpp
    index db01dce..54292d7 100644
    a b bool Settings::LoadSettingsFiles(QString filename, QString prefix, 
    115115{
    116116    int result = ReadSettings(prefix + "/share/mythtv/" + filename);
    117117    result += ReadSettings(prefix + "/etc/mythtv/" + filename);
    118     result += ReadSettings(confdir + "/" + filename);
     118    result += ReadSettings(confdir + '/' + filename);
    119119    result += ReadSettings("./" + filename);
    120120    return result;
    121121}
    bool Settings::ReadSettings(QString pszFile) 
    159159
    160160                (*m_pSettings)[strKey] = strVal;
    161161
    162                 VERBOSE(VB_FILE, LOC + "'" + strKey + "' = '" + strVal + "'.");
     162                VERBOSE(VB_FILE, LOC + '\'' + strKey + "' = '" + strVal + "'.");
    163163            }
    164164        }
    165165    } // wend