Ticket #6427: libs_libmythupnp-QString-efficiencies.patch

File libs_libmythupnp-QString-efficiencies.patch, 5.9 KB (added by Erik Hovland <erik@…>, 17 years ago)

Use QString when char* is less efficient, use ' instead of " to get chars instead of strings

  • mythtv/libs/libmythupnp/httprequest.cpp

    Uses single quotes and QString objects to improve efficiency.
    
    From: Erik Hovland <erik@hovland.org>
    
    
    ---
    
     mythtv/libs/libmythupnp/httprequest.cpp |    8 ++++----
     mythtv/libs/libmythupnp/ssdp.cpp        |    2 +-
     mythtv/libs/libmythupnp/upnpcds.cpp     |   10 +++++-----
     mythtv/libs/libmythupnp/upnpdevice.cpp  |    6 +++---
     4 files changed, 13 insertions(+), 13 deletions(-)
    
    
    diff --git a/mythtv/libs/libmythupnp/httprequest.cpp b/mythtv/libs/libmythupnp/httprequest.cpp
    index 37b4116..109e4cc 100644
    a b RequestType HTTPRequest::SetRequestType( const QString &sType )  
    171171    if (sType == "UNSUBSCRIBE") return( m_eType = RequestTypeUnsubscribe );
    172172    if (sType == "NOTIFY"     ) return( m_eType = RequestTypeNotify      );
    173173
    174     if (sType.startsWith( "HTTP/" )) return( m_eType = RequestTypeResponse );
     174    if (sType.startsWith( QString("HTTP/") )) return( m_eType = RequestTypeResponse );
    175175
    176176    VERBOSE( VB_UPNP, QString( "HTTPRequest::SentRequestType( %1 ) - returning Unknown." )
    177177                         .arg( sType ) );
    void HTTPRequest::ProcessRequestLine( const QString &sLine )  
    995995
    996996    // ----------------------------------------------------------------------
    997997
    998     if ( sLine.startsWith( "HTTP/" ))
     998    if ( sLine.startsWith( QString("HTTP/") ))
    999999        m_eType = RequestTypeResponse;
    10001000    else
    10011001        m_eType = RequestTypeUnknown;
    bool HTTPRequest::ProcessSOAPPayload( const QString &sSOAPAction )  
    11961196    // XML Document Loaded... now parse it
    11971197    // --------------------------------------------------------------
    11981198
    1199     m_sNameSpace    = sSOAPAction.section( "#", 0, 0).remove( 0, 1);
    1200     m_sMethod       = sSOAPAction.section( "#", 1 );
     1199    m_sNameSpace    = sSOAPAction.section( '#', 0, 0).remove( 0, 1);
     1200    m_sMethod       = sSOAPAction.section( '#', 1 );
    12011201    m_sMethod.remove( m_sMethod.length()-1, 1 );
    12021202
    12031203    QDomNodeList oNodeList = doc.elementsByTagNameNS( m_sNameSpace, m_sMethod );
  • mythtv/libs/libmythupnp/ssdp.cpp

    diff --git a/mythtv/libs/libmythupnp/ssdp.cpp b/mythtv/libs/libmythupnp/ssdp.cpp
    index cb81199..ae3d134 100644
    a b SSDPRequestType SSDP::ProcessRequestLine( const QString &sLine )  
    339339    //      <method> <Resource URI> HTTP/m.n
    340340    // ----------------------------------------------------------------------
    341341
    342     if ( sLine.startsWith( "HTTP/" ))
     342    if ( sLine.startsWith( QString("HTTP/") ))
    343343        return SSDP_MSearchResp;
    344344    else
    345345    {
  • mythtv/libs/libmythupnp/upnpcds.cpp

    diff --git a/mythtv/libs/libmythupnp/upnpcds.cpp b/mythtv/libs/libmythupnp/upnpcds.cpp
    index bd2f5b9..b63fc9b 100644
    a b void UPnpCDS::HandleBrowse( HTTPRequest *pRequest )  
    232232    short          nTotalMatches   = 0;
    233233    short          nUpdateID       = 0;
    234234    QString        sResultXML;
    235     FilterMap filter =  (FilterMap) request.m_sFilter.split(",");
     235    FilterMap filter =  (FilterMap) request.m_sFilter.split(',');
    236236
    237237    VERBOSE(VB_UPNP, QString("UPnpCDS::HandleBrowse ObjectID=%1, ContainerId=%2")
    238238                             .arg(request.m_sObjectId)
    void UPnpCDS::HandleSearch( HTTPRequest *pRequest )  
    473473
    474474        if (eErrorCode == UPnPResult_Success)
    475475        {
    476             FilterMap filter =  (FilterMap) request.m_sFilter.split(",");
     476            FilterMap filter =  (FilterMap) request.m_sFilter.split(',');
    477477            nNumberReturned = pResult->m_List.count();
    478478            nTotalMatches   = pResult->m_nTotalMatches;
    479479            nUpdateID       = pResult->m_nUpdateID;
    UPnpCDSExtensionResults *UPnpCDSExtension::Browse( UPnpCDSRequest *pRequest )  
    631631                    " ", QString::SkipEmptyParts);
    632632                idPath = idPath[0].split('?', QString::SkipEmptyParts);
    633633
    634                 if (idPath[0].startsWith("Id"))
     634                if (idPath[0].startsWith(QString("Id")))
    635635                    idPath[0] = QString("item=%1").arg(idPath[0].right(idPath[0].length() - 2));
    636636            }
    637637        }
    UPnpCDSExtensionResults *UPnpCDSExtension::Browse( UPnpCDSRequest *pRequest )  
    643643        if (sLast == m_sExtensionId         ) { return( ProcessRoot   ( pRequest, pResults, idPath )); }
    644644        if (sLast == "0"                    ) { return( ProcessAll    ( pRequest, pResults, idPath )); }
    645645
    646         if (sLast.startsWith("key" , Qt::CaseSensitive))
     646        if (sLast.startsWith(QString("key") , Qt::CaseSensitive))
    647647            return ProcessKey(pRequest, pResults, idPath);
    648648
    649         if (sLast.startsWith("item", Qt::CaseSensitive))
     649        if (sLast.startsWith(QString("item"), Qt::CaseSensitive))
    650650            return ProcessItem(pRequest, pResults, idPath);
    651651
    652652        int nNodeIdx = sLast.toInt();
  • mythtv/libs/libmythupnp/upnpdevice.cpp

    diff --git a/mythtv/libs/libmythupnp/upnpdevice.cpp b/mythtv/libs/libmythupnp/upnpdevice.cpp
    index 58b5e55..1c2429a 100644
    a b void UPnpDeviceDesc::OutputDevice( QTextStream &os,  
    377377    // ----------------------------------------------------------------------
    378378
    379379    bool bIsXbox360 =
    380         sUserAgent.startsWith("Xbox/2.0", Qt::CaseInsensitive) ||
    381         sUserAgent.startsWith( "Mozilla/4.0", Qt::CaseInsensitive);
     380        sUserAgent.startsWith(QString("Xbox/2.0"), Qt::CaseInsensitive) ||
     381        sUserAgent.startsWith( QString("Mozilla/4.0"), Qt::CaseInsensitive);
    382382
    383383    os << FormatValue( "manufacturer" , pDevice->m_sManufacturer    );
    384384    os << FormatValue( "modelURL"     , pDevice->m_sModelURL        );   
    UPnpDeviceDesc *UPnpDeviceDesc::Retrieve( QString &sURL, bool bInQtThread )  
    625625                                       NULL,  // login
    626626                                       bInQtThread );
    627627
    628     if (sXml.startsWith( "<?xml" ))
     628    if (sXml.startsWith( QString("<?xml") ))
    629629    {
    630630        QString sErrorMsg;
    631631