include/sfx2/dispatch.hxx|1 +
sfx2/source/control/dispatch.cxx |4 ++--
sfx2/source/inc/hintpost.hxx |7 ---
sfx2/source/notify/hintpost.cxx | 11 ---
4 files changed, 11 insertions(+), 12 deletions(-)
New commits:
commit 0783eeba65ec51051d072b6d4c6d32b3b45bee61
Author: Hassan Sajjad
AuthorDate: Mon Jan 29 21:00:15 2024 +0500
Commit: Hossein
CommitDate: Mon Mar 11 00:12:30 2024 +0100
Remove redundant function indirection in SfxHintPoster
SfxHintPoster::mLink always pointed to SfxDispatcher::PostMsgHandler and
except in ~SfxDispatcher, it was reinitialized to empty i.e. cleared.
This extra indirection is now removed.
SfxHintPoster was using SvRefBase to persist even after SfxDispatcher
was deleted and then deleted itself after SfxHintPoster::Post call was
completed. This extra indirection was adding 4-5 frames while debugging.
Change-Id: Ibfd6d3aea10ddf45732adc1a9d63a25717a771fa
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162700
Tested-by: Hossein
Reviewed-by: Hossein
diff --git a/include/sfx2/dispatch.hxx b/include/sfx2/dispatch.hxx
index 7216fc92badc..eea69d2a5abc 100644
--- a/include/sfx2/dispatch.hxx
+++ b/include/sfx2/dispatch.hxx
@@ -80,6 +80,7 @@ friend class SfxBindings;
friend class SfxStateCache;
friend class SfxPopupMenuManager;
friend class SfxHelp;
+friend class SfxHintPoster;
DECL_DLLPRIVATE_LINK( EventHdl_Impl, Timer *, void );
void PostMsgHandler(std::unique_ptr);
diff --git a/sfx2/source/control/dispatch.cxx b/sfx2/source/control/dispatch.cxx
index ccb0b0802f42..a780892b6940 100644
--- a/sfx2/source/control/dispatch.cxx
+++ b/sfx2/source/control/dispatch.cxx
@@ -303,7 +303,7 @@ void SfxDispatcher::Construct_Impl()
for (SfxObjectBars_Impl & rObjBar : xImp->aObjBars)
rObjBar.eId = ToolbarId::None;
-xImp->xPoster = new
SfxHintPoster(std::bind(&SfxDispatcher::PostMsgHandler, this,
std::placeholders::_1));
+xImp->xPoster = new SfxHintPoster(this);
xImp->aIdle.SetPriority(TaskPriority::HIGH_IDLE );
xImp->aIdle.SetInvokeHandler( LINK(this, SfxDispatcher, EventHdl_Impl ) );
@@ -335,7 +335,7 @@ SfxDispatcher::~SfxDispatcher()
// So that no timer by Reschedule in PlugComm strikes the
LeaveRegistrations
xImp->aIdle.Stop();
-xImp->xPoster->SetEventHdl( std::function)>() );
+xImp->xPoster->ClearLink();
// Notify the stack variables in Call_Impl
if ( xImp->pInCallAliveFlag )
diff --git a/sfx2/source/inc/hintpost.hxx b/sfx2/source/inc/hintpost.hxx
index ac37fde446ed..cca12647a283 100644
--- a/sfx2/source/inc/hintpost.hxx
+++ b/sfx2/source/inc/hintpost.hxx
@@ -23,6 +23,7 @@
#include
#include
#include
+#include
class SfxRequest;
@@ -41,17 +42,17 @@ class SfxRequest;
class SfxHintPoster final : public SvRefBase
{
private:
-std::function)> m_Link;
+class SfxDispatcher *m_Link;
DECL_LINK( DoEvent_Impl, void*, void );
virtual ~SfxHintPoster() override;
public:
-SfxHintPoster(std::function)> aLink);
+SfxHintPoster(SfxDispatcher *aLink);
voidPost( std::unique_ptr pHint );
-voidSetEventHdl(const std::function)>& rLink);
+voidClearLink();
};
#endif
diff --git a/sfx2/source/notify/hintpost.cxx b/sfx2/source/notify/hintpost.cxx
index 78c8c0499099..25d650de8ef2 100644
--- a/sfx2/source/notify/hintpost.cxx
+++ b/sfx2/source/notify/hintpost.cxx
@@ -25,8 +25,8 @@
#include
#include
-SfxHintPoster::SfxHintPoster(std::function)>
aLink)
-: m_Link(std::move(aLink))
+SfxHintPoster::SfxHintPoster(SfxDispatcher* aLink)
+: m_Link(aLink)
{
}
@@ -71,7 +71,7 @@ IMPL_LINK(SfxHintPoster, DoEvent_Impl, void*, pPostedHint,
void)
}
}
-m_Link(std::unique_ptr(pRequest));
+m_Link->PostMsgHandler(std::unique_ptr(pRequest));
if (bSetView)
{
@@ -83,9 +83,6 @@ IMPL_LINK(SfxHintPoster, DoEvent_Impl, void*, pPostedHint,
void)
ReleaseRef();
}
-void SfxHintPoster::SetEventHdl(const
std::function)>& rLink)
-{
-m_Link = rLink;
-}
+void SfxHintPoster::ClearLink() { m_Link = nullptr; }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */