diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2024-03-20 10:10:53 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2024-03-21 17:06:44 +0100 |
commit | b1be5fffeb2f845ad40d7f7ceff03f563ebcf8d4 (patch) | |
tree | 69fe7788f910e0fa5a66a53c0a702b304cbb9f52 | |
parent | 14bf98b9bb3765b935316bd3a972f8ef7bb4d21e (diff) |
avoid O(n^2) loop in writer
Change-Id: Iea5f98e5eb39fb6527be59f2f3dec89a41288a36
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165045
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | sw/source/uibase/shells/frmsh.cxx | 17 |
1 files changed, 2 insertions, 15 deletions
diff --git a/sw/source/uibase/shells/frmsh.cxx b/sw/source/uibase/shells/frmsh.cxx index 05176a0980f0..2785f7133031 100644 --- a/sw/source/uibase/shells/frmsh.cxx +++ b/sw/source/uibase/shells/frmsh.cxx @@ -81,17 +81,6 @@ using namespace ::com::sun::star::uno; // Prototypes static void lcl_FrameGetMaxLineWidth(const SvxBorderLine* pBorderLine, SvxBorderLine& rBorderLine); -static const SwFrameFormat* lcl_GetFrameFormatByName(SwWrtShell const & rSh, std::u16string_view rName) -{ - const size_t nCount = rSh.GetFlyCount(FLYCNTTYPE_FRM); - for( size_t i = 0; i < nCount; ++i ) - { - const SwFrameFormat* pFormat = rSh.GetFlyNum(i, FLYCNTTYPE_FRM); - if(pFormat->GetName() == rName) - return pFormat; - } - return nullptr; -} SFX_IMPL_INTERFACE(SwFrameShell, SwBaseShell) @@ -604,8 +593,7 @@ void SwFrameShell::Execute(SfxRequest &rReq) if (!sPrevName.isEmpty()) { //needs cast - no non-const method available - SwFrameFormat* pPrevFormat = const_cast<SwFrameFormat*>( - lcl_GetFrameFormatByName(rSh, sPrevName)); + SwFrameFormat* pPrevFormat = rSh.GetDoc()->GetFlyFrameFormatByName(sPrevName); SAL_WARN_IF(!pPrevFormat, "sw.ui", "No frame found!"); if(pPrevFormat) { @@ -636,8 +624,7 @@ void SwFrameShell::Execute(SfxRequest &rReq) if (!sNextName.isEmpty()) { //needs cast - no non-const method available - SwFrameFormat* pNextFormat = const_cast<SwFrameFormat*>( - lcl_GetFrameFormatByName(rSh, sNextName)); + SwFrameFormat* pNextFormat = rSh.GetDoc()->GetFlyFrameFormatByName(sNextName); SAL_WARN_IF(!pNextFormat, "sw.ui", "No frame found!"); if(pNextFormat) { |