Commit 4f2f3bde authored by Robert Krawitz's avatar Robert Krawitz

Minor point optimizations

parent 771d973d
......@@ -39,8 +39,8 @@ DB::MD5::MD5()
DB::MD5::MD5(const QString &md5str)
: m_isNull(md5str.isEmpty())
, m_v0(md5str.left(16).toULongLong(0, 16))
, m_v1(md5str.mid(16, 16).toULongLong(0, 16))
, m_v0(md5str.leftRef(16).toULongLong(0, 16))
, m_v1(md5str.midRef(16, 16).toULongLong(0, 16))
{
}
......@@ -55,8 +55,8 @@ DB::MD5 &DB::MD5::operator=(const QString &md5str)
m_isNull = true;
} else {
m_isNull = false;
m_v0 = md5str.left(16).toULongLong(0, 16);
m_v1 = md5str.mid(16, 16).toULongLong(0, 16);
m_v0 = md5str.leftRef(16).toULongLong(0, 16);
m_v1 = md5str.midRef(16, 16).toULongLong(0, 16);
}
return *this;
}
......
......@@ -31,7 +31,8 @@ QString Utilities::stripEndingForwardSlash(const QString &fileName)
QString Utilities::relativeFolderName(const QString &fileName)
{
int index = fileName.lastIndexOf(QChar::fromLatin1('/'), -1);
static QChar slash = QChar::fromLatin1('/');
int index = fileName.lastIndexOf(slash, -1);
if (index == -1)
return QString();
else
......@@ -40,16 +41,19 @@ QString Utilities::relativeFolderName(const QString &fileName)
QString Utilities::absoluteImageFileName(const QString &relativeName)
{
return stripEndingForwardSlash(Settings::SettingsData::instance()->imageDirectory()) + QString::fromLatin1("/") + relativeName;
static QString slash = QString::fromLatin1("/");
return stripEndingForwardSlash(Settings::SettingsData::instance()->imageDirectory()) + slash + relativeName;
}
QString Utilities::imageFileNameToAbsolute(const QString &fileName)
{
static QString slash = QString::fromLatin1("/");
static QString fileslashslash = QString::fromLatin1("file://");
if (fileName.startsWith(Settings::SettingsData::instance()->imageDirectory()))
return fileName;
else if (fileName.startsWith(QString::fromLatin1("file://")))
else if (fileName.startsWith(fileslashslash))
return imageFileNameToAbsolute(fileName.mid(7)); // 7 == length("file://")
else if (fileName.startsWith(QString::fromLatin1("/")))
else if (fileName.startsWith(slash))
return QString(); // Not within our image root
else
return absoluteImageFileName(fileName);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment