summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2021-07-17 19:02:30 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-07-18 09:06:07 +0200
commit5db3a12dffd6edc96474a470728c1b89e129ca36 (patch)
tree75138a42f7f60a2b3d2738ae3e22b6fa3e07c39a
parent5060c0c8b9070c3093bf036de31c551ceb109ca7 (diff)
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@collabora.co.uk>
-rw-r--r--unotools/source/i18n/textsearch.cxx22
1 files changed, 10 insertions, 12 deletions
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 )