Commit 5dbeef5f authored by Igor Kushnir's avatar Igor Kushnir
Browse files

ContextBrowserPlugin: remove redundant DUChain read locks

DUChain read locks are recursive, so this commit does not fix anything,
only improves performance. The removed locks were redundant because:
1. ContextBrowserPlugin::findDeclaration() is called only from
   ContextBrowserPlugin::updateForView() while holding DUChain::lock().
2. ContextBrowserPlugin::switchUse() acquires DUChain::lock() almost at
   the beginning => no need to acquire it again below.

Michael Swan originally proposed similar changes in
https://phabricator.kde.org/D22182 along with a fix for Bug 358787.
Jonathan L. Verner reinvented the same fix, but for Bug 416714, in the
parent of this commit. This commit modifies and applies the remaining
fixes from the Phabricator review.

The Phabricator review's summary contains:
  "There were two paths which needed a lock added given my change, so
  this change set should not cause any regression on bug #386901."
As explained at the top of this commit message, the moved/removed locks
were just redundant, and so removing them is unrelated to the bug fix.
parent a947074f
Pipeline #171397 passed with stage
in 22 minutes and 21 seconds
......@@ -777,6 +777,8 @@ void ContextBrowserPlugin::addHighlight(View* view, KDevelop::Declaration* decl)
Declaration* ContextBrowserPlugin::findDeclaration(View* view, const KTextEditor::Cursor& position, bool mouseHighlight)
{
Q_UNUSED(mouseHighlight);
ENSURE_CHAIN_READ_LOCKED
Declaration* foundDeclaration = nullptr;
if (m_useDeclaration.data()) {
foundDeclaration = m_useDeclaration.data();
......@@ -788,7 +790,6 @@ Declaration* ContextBrowserPlugin::findDeclaration(View* view, const KTextEditor
if (foundDeclaration && foundDeclaration->kind() == Declaration::Alias) {
auto* alias = dynamic_cast<AliasDeclaration*>(foundDeclaration);
Q_ASSERT(alias);
DUChainReadLocker lock;
foundDeclaration = alias->aliasedDeclaration().declaration();
}
}
......@@ -1071,7 +1072,6 @@ void ContextBrowserPlugin::switchUse(bool forward)
if (decl && decl->kind() == Declaration::Alias) {
auto* alias = dynamic_cast<AliasDeclaration*>(decl);
Q_ASSERT(alias);
DUChainReadLocker lock;
decl = alias->aliasedDeclaration().declaration();
}
......
Supports Markdown
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