From cf15c4dad74e31a035c0d1ca899dfbef4da90ad2 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Wed, 23 Jun 2021 08:51:05 +0200 Subject: tdf#135316 optimise SwCharFormats::FindFormatByName reduces load time by 10% Change-Id: Ic5c90588825592245d09f8ebe03b13e34676496a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117699 Tested-by: Jenkins Reviewed-by: Noel Grandin --- sw/source/core/unocore/unosett.cxx | 13 +------------ sw/source/core/unocore/unostyle.cxx | 2 +- 2 files changed, 2 insertions(+), 13 deletions(-) (limited to 'sw/source/core/unocore') diff --git a/sw/source/core/unocore/unosett.cxx b/sw/source/core/unocore/unosett.cxx index 186b0e98116e..101a70f10ada 100644 --- a/sw/source/core/unocore/unosett.cxx +++ b/sw/source/core/unocore/unosett.cxx @@ -1589,21 +1589,10 @@ void SwXNumberingRules::SetPropertiesToNumFormat( } else if (pLocalDoc) { - const SwCharFormats* pFormats = pLocalDoc->GetCharFormats(); - const size_t nChCount = pFormats->size(); - SwCharFormat* pCharFormat = nullptr; if (!sCharFormatName.isEmpty()) { - for(size_t j = 0; j< nChCount; ++j) - { - SwCharFormat* pTmp = (*pFormats)[j]; - if(pTmp->GetName() == sCharFormatName) - { - pCharFormat = pTmp; - break; - } - } + pCharFormat = pLocalDoc->FindCharFormatByName(sCharFormatName); if(!pCharFormat) { diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index a6a14abef2dc..86d9381b8573 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -891,7 +891,7 @@ uno::Any XStyleFamily::getByName(const OUString& rName) throw uno::RuntimeException(); SfxStyleSheetBase* pBase = m_pBasePool->Find(sStyleName, m_rEntry.m_eFamily); if(!pBase) - throw container::NoSuchElementException(); + throw container::NoSuchElementException(rName); uno::Reference xStyle = FindStyle(sStyleName); if(!xStyle.is()) xStyle = m_rEntry.m_fCreateStyle(m_pBasePool, m_pDocShell, m_rEntry.m_eFamily == SfxStyleFamily::Frame ? pBase->GetName() : sStyleName); -- cgit v1.2.3