mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-07-31 11:20:22 +02:00
Faster cacheKey
This commit is contained in:
@@ -49,9 +49,24 @@ static QMutex s_nameCacheMutex;
|
|||||||
inline QString
|
inline QString
|
||||||
cacheKey( const QString& artist, const QString& track, const QString& album, int duration, const QString& composer, unsigned int albumpos, unsigned int discnumber )
|
cacheKey( const QString& artist, const QString& track, const QString& album, int duration, const QString& composer, unsigned int albumpos, unsigned int discnumber )
|
||||||
{
|
{
|
||||||
|
const QString durationStr = QString::number( duration );
|
||||||
|
const QString albumposStr = QString::number( albumpos );
|
||||||
|
const QString discnumberStr = QString::number( discnumber );
|
||||||
QString str;
|
QString str;
|
||||||
QTextStream stream( &str );
|
// Preallocate space so that we will only call malloc once.
|
||||||
stream << artist << track << album << composer << duration << albumpos << discnumber;
|
// With Qt5 we can possibly revert back to just "+" these strings.
|
||||||
|
// The "+" implementation in Qt4 differs slighty depending on compile
|
||||||
|
// options which could drastically reduce the performance.
|
||||||
|
str.reserve( artist.size() + track.size() + album.size()
|
||||||
|
+ composer.size() + durationStr.size()
|
||||||
|
+ albumposStr.size() + discnumberStr.size() );
|
||||||
|
str += artist;
|
||||||
|
str += track;
|
||||||
|
str += album;
|
||||||
|
str += composer;
|
||||||
|
str += durationStr;
|
||||||
|
str += albumposStr;
|
||||||
|
str += discnumberStr;
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user