Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Utilities
Ark
Commits
720ce03e
Commit
720ce03e
authored
Mar 15, 2021
by
Nicolas Fella
Browse files
Avoid QString (de)allocations in Entry::find
Use QStringView to avoid unnecessary (de)allocations
parent
e7cf7ebb
Changes
2
Hide whitespace changes
Inline
Side-by-side
kerfuffle/archiveentry.cpp
View file @
720ce03e
...
...
@@ -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
(
QString
View
name
)
const
{
for
(
Entry
*
entry
:
qAsConst
(
m_entries
))
{
if
(
entry
&&
(
entry
->
name
()
==
name
))
{
if
(
entry
&&
(
entry
->
name
View
()
==
name
))
{
return
entry
;
}
}
...
...
kerfuffle/archiveentry.h
View file @
720ce03e
...
...
@@ -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
(
QString
View
name
)
const
;
Entry
*
findByPath
(
const
QStringList
&
pieces
,
int
index
=
0
)
const
;
QIcon
icon
()
const
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment