Commit 720ce03e authored by Nicolas Fella's avatar Nicolas Fella
Browse files

Avoid QString (de)allocations in Entry::find

Use QStringView to avoid unnecessary (de)allocations
parent e7cf7ebb
......@@ -131,6 +131,11 @@ QString Archive::Entry::name() const
return m_name;
}
QStringView Archive::Entry::nameView() const
{
return m_name;
}
void Archive::Entry::setIsDirectory(const bool isDirectory)
{
m_isDirectory = isDirectory;
......@@ -159,10 +164,10 @@ int Archive::Entry::row() const
return 0;
}
Archive::Entry *Archive::Entry::find(const QString &name) const
Archive::Entry *Archive::Entry::find(QStringView name) const
{
for (Entry *entry : qAsConst(m_entries)) {
if (entry && (entry->name() == name)) {
if (entry && (entry->nameView() == name)) {
return entry;
}
}
......
......@@ -87,12 +87,13 @@ public:
void setFullPath(const QString &fullPath);
QString fullPath(PathFormat format = WithTrailingSlash) const;
QString name() const;
QStringView nameView() const;
void setIsDirectory(const bool isDirectory);
bool isDir() const;
void setIsExecutable(const bool isExecutable);
bool isExecutable() const;
int row() const;
Entry *find(const QString &name) const;
Entry *find(QStringView name) const;
Entry *findByPath(const QStringList & pieces, int index = 0) const;
QIcon icon() const;
......
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