Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Marco Bubke
flatpak-qt-creator
Commits
c14896b7
Commit
c14896b7
authored
Dec 05, 2008
by
Thorbjørn Lindeijer
Browse files
Slight optimization in Session::projectForFile
Avoid creating a copy of the list of projects.
parent
310d50fd
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/plugins/cpptools/searchsymbols.cpp
View file @
c14896b7
...
...
@@ -194,7 +194,7 @@ QString SearchSymbols::symbolName(const Symbol *symbol) const
void
SearchSymbols
::
appendItem
(
const
QString
&
name
,
const
QString
&
info
,
ModelItemInfo
::
ItemType
type
,
const
CPlusPlus
::
Symbol
*
symbol
)
const
Symbol
*
symbol
)
{
const
QIcon
icon
=
icons
.
iconForSymbol
(
symbol
);
items
.
append
(
ModelItemInfo
(
name
,
info
,
type
,
...
...
src/plugins/projectexplorer/session.cpp
View file @
c14896b7
...
...
@@ -709,7 +709,7 @@ void SessionManager::editDependencies()
dlg
.
exec
();
}
QList
<
Project
*>
SessionManager
::
projects
()
const
const
QList
<
Project
*>
&
SessionManager
::
projects
()
const
{
return
m_file
->
m_projects
;
}
...
...
@@ -839,26 +839,26 @@ Project *SessionManager::projectForFile(const QString &fileName) const
if
(
debug
)
qDebug
()
<<
"SessionManager::projectForFile("
<<
fileName
<<
")"
;
Project
*
project
=
0
;
const
QList
<
Project
*
>
&
project
List
=
projects
()
;
QList
<
Project
*>
projectList
=
projects
();
// Check current project first
Project
*
currentProject
=
ProjectExplorerPlugin
::
instance
()
->
currentProject
();
if
(
currentProject
&&
projectContainsFile
(
currentProject
,
fileName
))
return
currentProject
;
// Always check current project first
if
(
Project
*
currentProject
=
ProjectExplorerPlugin
::
instance
()
->
currentProject
())
{
projectList
.
removeOne
(
currentProject
);
projectList
.
insert
(
0
,
currentProject
);
}
foreach
(
Project
*
p
,
projectList
)
if
(
p
!=
currentProject
&&
projectContainsFile
(
p
,
fileName
))
return
p
;
foreach
(
Project
*
p
,
projectList
)
{
if
(
!
m_projectFileCache
.
contains
(
p
))
{
m_projectFileCache
.
insert
(
p
,
p
->
files
(
Project
::
AllFiles
));
}
if
(
m_projectFileCache
.
value
(
p
).
contains
(
fileName
))
{
project
=
p
;
break
;
}
}
return
project
;
return
0
;
}
bool
SessionManager
::
projectContainsFile
(
Project
*
p
,
const
QString
&
fileName
)
const
{
if
(
!
m_projectFileCache
.
contains
(
p
))
m_projectFileCache
.
insert
(
p
,
p
->
files
(
Project
::
AllFiles
));
return
m_projectFileCache
.
value
(
p
).
contains
(
fileName
);
}
void
SessionManager
::
setEditorCodec
(
Core
::
IEditor
*
editor
,
const
QString
&
fileName
)
...
...
src/plugins/projectexplorer/session.h
View file @
c14896b7
...
...
@@ -137,7 +137,7 @@ public:
Core
::
IFile
*
file
()
const
;
Project
*
startupProject
()
const
;
QList
<
Project
*>
projects
()
const
;
const
QList
<
Project
*>
&
projects
()
const
;
bool
isDefaultVirgin
()
const
;
bool
isDefaultSession
(
const
QString
&
session
)
const
;
...
...
@@ -182,6 +182,7 @@ private:
bool
loadImpl
(
const
QString
&
fileName
);
bool
createImpl
(
const
QString
&
fileName
);
QString
sessionNameToFileName
(
const
QString
&
session
);
bool
projectContainsFile
(
Project
*
p
,
const
QString
&
fileName
)
const
;
bool
recursiveDependencyCheck
(
const
QString
&
newDep
,
const
QString
&
checkDep
)
const
;
QStringList
dependencies
(
const
QString
&
proName
)
const
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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