QString has a few efficiency tricks that can be employed.
From: Erik Hovland <erik@hovland.org>
---
mythtv/libs/libmythupnp/configuration.cpp | 6 ++---
mythtv/libs/libmythupnp/httprequest.cpp | 34 ++++++++++++++--------------
mythtv/libs/libmythupnp/soapclient.cpp | 14 ++++++------
mythtv/libs/libmythupnp/upnpcds.cpp | 4 ++-
mythtv/libs/libmythupnp/upnpcdsobjects.cpp | 2 +-
mythtv/libs/libmythupnp/upnpcmgr.cpp | 4 ++-
mythtv/libs/libmythupnp/upnputil.cpp | 6 ++---
mythtv/libs/libmythupnp/upnputil.h | 2 +-
8 files changed, 36 insertions(+), 36 deletions(-)
diff --git a/mythtv/libs/libmythupnp/configuration.cpp b/mythtv/libs/libmythupnp/configuration.cpp
index a1ad1e9..b7faa56 100644
a
|
b
|
XmlConfiguration::XmlConfiguration( const QString &sFileName ) |
37 | 37 | |
38 | 38 | bool XmlConfiguration::Load( void ) |
39 | 39 | { |
40 | | QString sName = m_sPath + "/" + m_sFileName; |
| 40 | QString sName = m_sPath + '/' + m_sFileName; |
41 | 41 | |
42 | 42 | QFile file( sName ); |
43 | 43 | |
… |
… |
bool XmlConfiguration::Save( void ) |
88 | 88 | if (m_sFileName.isEmpty()) // Special case. No file is created |
89 | 89 | return true; |
90 | 90 | |
91 | | QString sName = m_sPath + "/" + m_sFileName; |
| 91 | QString sName = m_sPath + '/' + m_sFileName; |
92 | 92 | |
93 | 93 | QFile file( sName ); |
94 | 94 | |
… |
… |
bool XmlConfiguration::Save( void ) |
129 | 129 | |
130 | 130 | QDomNode XmlConfiguration::FindNode( const QString &sName, bool bCreate ) |
131 | 131 | { |
132 | | QStringList parts = sName.split("/", QString::SkipEmptyParts); |
| 132 | QStringList parts = sName.split('/', QString::SkipEmptyParts); |
133 | 133 | |
134 | 134 | return FindNode( parts, m_rootNode, bCreate ); |
135 | 135 | |
diff --git a/mythtv/libs/libmythupnp/httprequest.cpp b/mythtv/libs/libmythupnp/httprequest.cpp
index fb7f3c6..bae5f22 100644
a
|
b
|
void HTTPRequest::Reset() |
128 | 128 | m_response << flush; |
129 | 129 | m_aBuffer.truncate( 0 ); |
130 | 130 | |
131 | | m_sRawRequest = QString(); |
132 | | m_sBaseUrl = QString(); |
133 | | m_sMethod = QString(); |
| 131 | m_sRawRequest.clear(); |
| 132 | m_sBaseUrl.clear(); |
| 133 | m_sMethod.clear(); |
134 | 134 | |
135 | 135 | m_mapParams.clear(); |
136 | 136 | m_mapHeaders.clear(); |
137 | 137 | |
138 | | m_sPayload = QString(); |
| 138 | m_sPayload.clear(); |
139 | 139 | |
140 | | m_sProtocol = QString(); |
141 | | m_sNameSpace = QString(); |
| 140 | m_sProtocol.clear(); |
| 141 | m_sNameSpace.clear(); |
142 | 142 | |
143 | 143 | m_mapRespHeaders.clear(); |
144 | 144 | |
145 | | m_sFileName = QString(); |
| 145 | m_sFileName.clear(); |
146 | 146 | } |
147 | 147 | |
148 | 148 | ///////////////////////////////////////////////////////////////////////////// |
… |
… |
long HTTPRequest::GetParameters( QString sParams, QStringMap &mapParams ) |
736 | 736 | sParams.replace( "%26", "&" ); |
737 | 737 | |
738 | 738 | if (sParams.length() > 0) |
739 | | { |
740 | | QStringList params = sParams.split("&", QString::SkipEmptyParts); |
| 739 | { |
| 740 | QStringList params = sParams.split('&', QString::SkipEmptyParts); |
741 | 741 | |
742 | 742 | for ( QStringList::Iterator it = params.begin(); |
743 | 743 | it != params.end(); ++it ) |
… |
… |
bool HTTPRequest::ParseRange( QString sRange, |
1039 | 1039 | // Split multiple ranges |
1040 | 1040 | // ---------------------------------------------------------------------- |
1041 | 1041 | |
1042 | | QStringList ranges = sRange.split(",", QString::SkipEmptyParts); |
| 1042 | QStringList ranges = sRange.split(',', QString::SkipEmptyParts); |
1043 | 1043 | |
1044 | 1044 | if (ranges.count() == 0) |
1045 | 1045 | return false; |
… |
… |
bool HTTPRequest::ParseRange( QString sRange, |
1048 | 1048 | // Split first range into its components |
1049 | 1049 | // ---------------------------------------------------------------------- |
1050 | 1050 | |
1051 | | QStringList parts = ranges[0].split("-"); |
| 1051 | QStringList parts = ranges[0].split('-'); |
1052 | 1052 | |
1053 | 1053 | if (parts.count() != 2) |
1054 | 1054 | return false; |
… |
… |
bool HTTPRequest::ParseRange( QString sRange, |
1112 | 1112 | |
1113 | 1113 | void HTTPRequest::ExtractMethodFromURL() |
1114 | 1114 | { |
1115 | | QStringList sList = m_sBaseUrl.split("/", QString::SkipEmptyParts); |
| 1115 | QStringList sList = m_sBaseUrl.split('/', QString::SkipEmptyParts); |
1116 | 1116 | |
1117 | 1117 | m_sMethod = ""; |
1118 | 1118 | |
… |
… |
void HTTPRequest::ExtractMethodFromURL() |
1122 | 1122 | sList.pop_back(); |
1123 | 1123 | } |
1124 | 1124 | |
1125 | | m_sBaseUrl = "/" + sList.join( "/" ); |
| 1125 | m_sBaseUrl = '/' + sList.join( "/" ); |
1126 | 1126 | //VERBOSE(VB_UPNP, QString("ExtractMethodFromURL : %1 : ").arg(m_sMethod)); |
1127 | 1127 | } |
1128 | 1128 | |
… |
… |
QString HTTPRequest::Encode(const QString &sIn) |
1210 | 1210 | QString sStr = sIn; |
1211 | 1211 | //VERBOSE(VB_UPNP, QString("HTTPRequest::Encode Input : %1").arg(sStr)); |
1212 | 1212 | sStr.replace("&(?!(amp|lt|gt|quot|apos);)", "&" ); // This _must_ come first |
1213 | | sStr.replace("<", "<" ); |
1214 | | sStr.replace(">", ">" ); |
1215 | | sStr.replace("\"", """); |
1216 | | sStr.replace("'", "'"); |
| 1213 | sStr.replace('<', "<" ); |
| 1214 | sStr.replace('>', ">" ); |
| 1215 | sStr.replace('"', """); |
| 1216 | sStr.replace('\'', "'"); |
1217 | 1217 | //VERBOSE(VB_UPNP, QString("HTTPRequest::Encode Output : %1").arg(sStr)); |
1218 | 1218 | return sStr; |
1219 | 1219 | } |
diff --git a/mythtv/libs/libmythupnp/soapclient.cpp b/mythtv/libs/libmythupnp/soapclient.cpp
index 287c48d..be0667b 100644
a
|
b
|
SOAPClient::~SOAPClient() |
43 | 43 | |
44 | 44 | QDomNode SOAPClient::FindNode( const QString &sName, QDomNode &baseNode ) |
45 | 45 | { |
46 | | QStringList parts = sName.split("/", QString::SkipEmptyParts); |
| 46 | QStringList parts = sName.split('/', QString::SkipEmptyParts); |
47 | 47 | |
48 | 48 | return FindNode( parts, baseNode ); |
49 | 49 | |
… |
… |
bool SOAPClient::GetNodeValue( QDomNode &node, const QString &sName, bool bDefau |
89 | 89 | QString sDefault = (bDefault) ? "true" : "false"; |
90 | 90 | QString sValue = GetNodeValue( node, sName, sDefault ); |
91 | 91 | |
92 | | if (sValue.startsWith( "T" , Qt::CaseInsensitive ) || |
93 | | sValue.startsWith( "Y" , Qt::CaseInsensitive ) || |
94 | | sValue.startsWith( "1" , Qt::CaseInsensitive ) ) |
| 92 | if (sValue.startsWith( 'T' , Qt::CaseInsensitive ) || |
| 93 | sValue.startsWith( 'Y' , Qt::CaseInsensitive ) || |
| 94 | sValue.startsWith( '1' , Qt::CaseInsensitive ) ) |
95 | 95 | { |
96 | 96 | return true; |
97 | 97 | } |
98 | 98 | |
99 | | if (sValue.startsWith( "F" , Qt::CaseInsensitive ) || |
100 | | sValue.startsWith( "N" , Qt::CaseInsensitive ) || |
101 | | sValue.startsWith( "0" , Qt::CaseInsensitive ) ) |
| 99 | if (sValue.startsWith( 'F' , Qt::CaseInsensitive ) || |
| 100 | sValue.startsWith( 'N' , Qt::CaseInsensitive ) || |
| 101 | sValue.startsWith( '0' , Qt::CaseInsensitive ) ) |
102 | 102 | { |
103 | 103 | return false; |
104 | 104 | } |
diff --git a/mythtv/libs/libmythupnp/upnpcds.cpp b/mythtv/libs/libmythupnp/upnpcds.cpp
index ec6ff03..7132890 100644
a
|
b
|
UPnpCDSExtensionResults *UPnpCDSExtension::Browse( UPnpCDSRequest *pRequest ) |
615 | 615 | { |
616 | 616 | idPath = idPath[idPath.count() - 2].split( |
617 | 617 | " ", QString::SkipEmptyParts); |
618 | | idPath = idPath[0].split("?", QString::SkipEmptyParts); |
| 618 | idPath = idPath[0].split('?', QString::SkipEmptyParts); |
619 | 619 | |
620 | 620 | if (idPath[0].startsWith("Id")) |
621 | 621 | idPath[0] = QString("item=%1").arg(idPath[0].right(idPath[0].length() - 2)); |
… |
… |
UPnpCDSExtensionResults *UPnpCDSExtension::ProcessContainer( UPnpCDSRequest |
1053 | 1053 | |
1054 | 1054 | QString sSQL = pInfo->sql; |
1055 | 1055 | |
1056 | | sSQL.replace( "%1", "" ); |
| 1056 | sSQL.remove( "%1" ); |
1057 | 1057 | |
1058 | 1058 | sSQL += QString( " LIMIT %2, %3" ) |
1059 | 1059 | .arg( pRequest->m_nStartingIndex ) |
diff --git a/mythtv/libs/libmythupnp/upnpcdsobjects.cpp b/mythtv/libs/libmythupnp/upnpcdsobjects.cpp
index 2ce53bc..d50add4 100644
a
|
b
|
void CDSObject::toXml(QTextStream &os) const |
227 | 227 | QString sName; |
228 | 228 | |
229 | 229 | if (pProp->m_sNameSpace.length() > 0) |
230 | | sName = pProp->m_sNameSpace + ":" + pProp->m_sName; |
| 230 | sName = pProp->m_sNameSpace + ':' + pProp->m_sName; |
231 | 231 | else |
232 | 232 | sName = pProp->m_sName; |
233 | 233 | |
diff --git a/mythtv/libs/libmythupnp/upnpcmgr.cpp b/mythtv/libs/libmythupnp/upnpcmgr.cpp
index d3075d2..66f3057 100644
a
|
b
|
void UPnpCMGR::AddSourceProtocol( const QString &sProtocol ) |
58 | 58 | QString sValue = GetValue< QString >( "SourceProtocolInfo" ); |
59 | 59 | |
60 | 60 | if (sValue.length() > 0 ) |
61 | | sValue += ","; |
| 61 | sValue += ','; |
62 | 62 | |
63 | 63 | sValue += sProtocol; |
64 | 64 | |
… |
… |
void UPnpCMGR::AddSinkProtocol( const QString &sProtocol ) |
74 | 74 | QString sValue = GetValue< QString >( "SinkProtocolInfo" ); |
75 | 75 | |
76 | 76 | if (sValue.length() > 0 ) |
77 | | sValue += ","; |
| 77 | sValue += ','; |
78 | 78 | |
79 | 79 | sValue += sProtocol; |
80 | 80 | |
diff --git a/mythtv/libs/libmythupnp/upnputil.cpp b/mythtv/libs/libmythupnp/upnputil.cpp
index 00e0fe1..a973763 100644
a
|
b
|
|
37 | 37 | |
38 | 38 | QString LookupUDN( QString sDeviceType ) |
39 | 39 | { |
40 | | QStringList sList = sDeviceType.split(":", QString::SkipEmptyParts); |
41 | | QString sLoc = "LookupUDN(" + sDeviceType + ")"; |
| 40 | QStringList sList = sDeviceType.split(':', QString::SkipEmptyParts); |
| 41 | QString sLoc = "LookupUDN(" + sDeviceType + ')'; |
42 | 42 | QString sName; |
43 | 43 | QString sUDN; |
44 | 44 | |
45 | 45 | if (sList.size() <= 2) |
46 | 46 | { |
47 | 47 | VERBOSE(VB_IMPORTANT, sLoc + "- bad device type, not enough tokens"); |
48 | | return QString::null; |
| 48 | return QString(); |
49 | 49 | } |
50 | 50 | |
51 | 51 | sName = "UPnP/UDN/" + sList[ sList.size() - 2 ]; |
diff --git a/mythtv/libs/libmythupnp/upnputil.h b/mythtv/libs/libmythupnp/upnputil.h
index 7e7936e..db6ee42 100644
a
|
b
|
class NameValue |
52 | 52 | |
53 | 53 | public: |
54 | 54 | NameValue() : |
55 | | sName(QString::null), sValue(QString::null), pAttributes(NULL) { } |
| 55 | sName(), sValue(), pAttributes(NULL) { } |
56 | 56 | NameValue(const QString &name, const QString &value) : |
57 | 57 | sName(name), sValue(value), pAttributes(NULL) { } |
58 | 58 | NameValue(const QString &name, const char *value) : |