[Libreoffice-commits] core.git: unotools/source
Noel Grandin (via logerrit)
logerrit at kemper.freedesktop.org
Sun Jul 18 07:06:40 UTC 2021
unotools/source/i18n/textsearch.cxx | 22 ++++++++++------------
1 file changed, 10 insertions(+), 12 deletions(-)
New commits:
commit 5db3a12dffd6edc96474a470728c1b89e129ca36
Author: Noel Grandin <noelgrandin at gmail.com>
AuthorDate: Sat Jul 17 19:02:30 2021 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Sun Jul 18 09:06:07 2021 +0200
osl::Mutex->std::mutex in CachedTextSearch
and drop an rtl::Static
Change-Id: I17bd6ad0b81ecb947e4306819ddc7d83f8a51dba
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119112
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/unotools/source/i18n/textsearch.cxx b/unotools/source/i18n/textsearch.cxx
index aae6cc573634..38c089f7c835 100644
--- a/unotools/source/i18n/textsearch.cxx
+++ b/unotools/source/i18n/textsearch.cxx
@@ -35,6 +35,7 @@
#include <rtl/instance.hxx>
#include <rtl/ustrbuf.hxx>
#include <tools/diagnose_ex.h>
+#include <mutex>
using namespace ::com::sun::star::util;
using namespace ::com::sun::star::uno;
@@ -93,30 +94,27 @@ namespace
{
struct CachedTextSearch
{
- ::osl::Mutex mutex;
+ std::mutex mutex;
i18nutil::SearchOptions2 Options;
css::uno::Reference< css::util::XTextSearch2 > xTextSearch;
};
-
- struct theCachedTextSearch
- : public rtl::Static< CachedTextSearch, theCachedTextSearch > {};
}
Reference<XTextSearch2> TextSearch::getXTextSearch( const i18nutil::SearchOptions2& rPara )
{
- CachedTextSearch &rCache = theCachedTextSearch::get();
+ static CachedTextSearch theCachedTextSearch;
- osl::MutexGuard aGuard(rCache.mutex);
+ std::lock_guard aGuard(theCachedTextSearch.mutex);
- if ( lcl_Equals(rCache.Options, rPara) )
- return rCache.xTextSearch;
+ if ( lcl_Equals(theCachedTextSearch.Options, rPara) )
+ return theCachedTextSearch.xTextSearch;
Reference< XComponentContext > xContext = ::comphelper::getProcessComponentContext();
- rCache.xTextSearch.set( ::TextSearch2::create(xContext) );
- rCache.xTextSearch->setOptions2( rPara.toUnoSearchOptions2() );
- rCache.Options = rPara;
+ theCachedTextSearch.xTextSearch.set( ::TextSearch2::create(xContext) );
+ theCachedTextSearch.xTextSearch->setOptions2( rPara.toUnoSearchOptions2() );
+ theCachedTextSearch.Options = rPara;
- return rCache.xTextSearch;
+ return theCachedTextSearch.xTextSearch;
}
TextSearch::TextSearch(const SearchParam & rParam, LanguageType eLang )
More information about the Libreoffice-commits
mailing list