summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2022-08-17 12:59:51 +0200
committerXisco Fauli <xiscofauli@libreoffice.org>2022-08-18 10:10:18 +0200
commitdbfa68a56f087f06ac325a442c6cb0e99f3ecd53 (patch)
tree4892697f28fc224c6d89581a5e1252338c87c6d0
parenttdf#150170: Revert "flatten TableType in ColumnSpanSet" (diff)
downloadcore-dbfa68a56f087f06ac325a442c6cb0e99f3ecd53.tar.gz
core-dbfa68a56f087f06ac325a442c6cb0e99f3ecd53.zip
tdf#150452: Revert "tdf#130795 use concurrent hashmap in SharedStringPool"
This commit reverts 3749d9af3745c0eaff7239e379578e4e2af89e9d which removes the dependency on the external library cuckoo Without using cuckoo the same file in tdf#130795 takes real 0m4,892s user 0m5,298s sys 0m0,449s With it, it takes real 0m4,914s user 0m5,276s sys 0m0,444s pretty much the same time Change-Id: I4cc9000ac5bf26de22bb9835283ae8d5b3230196 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138435 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org> Signed-off-by: Xisco Fauli <xiscofauli@libreoffice.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138446
-rw-r--r--Makefile.fetch1
-rw-r--r--RepositoryExternal.mk33
-rwxr-xr-xbin/oss-fuzz-setup.sh1
-rw-r--r--config_host.mk.in2
-rw-r--r--configure.ac26
-rw-r--r--distro-configs/LibreOfficeCoverity.conf1
-rw-r--r--distro-configs/LibreOfficeFlatpak.conf1
-rw-r--r--download.lst2
-rw-r--r--external/Module_external.mk1
-rw-r--r--external/cuckoo/Makefile7
-rw-r--r--external/cuckoo/Module_cuckoo.mk16
-rw-r--r--external/cuckoo/README3
-rw-r--r--external/cuckoo/UnpackedTarball_cuckoo.mk22
-rw-r--r--external/cuckoo/cuckoo-coverity.patch22
-rw-r--r--readlicense_oo/license/license.xml6
-rw-r--r--solenv/flatpak-manifest.in7
-rw-r--r--svl/Library_svl.mk1
-rw-r--r--svl/source/misc/sharedstringpool.cxx161
18 files changed, 72 insertions, 241 deletions
diff --git a/Makefile.fetch b/Makefile.fetch
index 85e2136b9d27..3c5b7ed1ee01 100644
--- a/Makefile.fetch
+++ b/Makefile.fetch
@@ -117,7 +117,6 @@ $(WORKDIR)/download: $(BUILDDIR)/config_$(gb_Side).mk $(SRCDIR)/download.lst $(S
$(call fetch_Optional,COINMP,COINMP_TARBALL) \
$(call fetch_Optional,CPPUNIT,CPPUNIT_TARBALL) \
$(call fetch_Optional,CT2N,CT2N_TARBALL) \
- $(call fetch_Optional,CUCKOO,CUCKOO_TARBALL) \
$(call fetch_Optional,CURL,CURL_TARBALL) \
$(call fetch_Optional,EBOOK,EBOOK_TARBALL) \
$(call fetch_Optional,EPM,EPM_TARBALL) \
diff --git a/RepositoryExternal.mk b/RepositoryExternal.mk
index 4854a20aa050..414c4bba741d 100644
--- a/RepositoryExternal.mk
+++ b/RepositoryExternal.mk
@@ -4309,37 +4309,4 @@ endif # ENABLE_ZXING
endif # SYSTEM_ZXING
-
-
-ifneq ($(SYSTEM_CUCKOO),)
-
-gb_ExternalProject__use_cuckoo_headers :=
-
-define gb_LinkTarget__use_cuckoo_headers
-$(call gb_LinkTarget_set_include,$(1),\
- -I$(call gb_UnpackedTarball_get_dir,cuckoo) \
- $$(INCLUDE) \
-)
-
-endef
-
-else # !SYSTEM_CUCKOO
-
-define gb_ExternalProject__use_cuckoo_headers
-$(call gb_ExternalProject_use_unpacked,$(1),cuckoo)
-
-endef
-
-define gb_LinkTarget__use_cuckoo_headers
-$(call gb_LinkTarget_use_unpacked,$(1),cuckoo)
-$(call gb_LinkTarget_set_include,$(1),\
- -I$(call gb_UnpackedTarball_get_dir,cuckoo) \
- $$(INCLUDE) \
-)
-
-endef
-
-endif # SYSTEM_CUCKOO
-
-
# vim: set noet sw=4 ts=4:
diff --git a/bin/oss-fuzz-setup.sh b/bin/oss-fuzz-setup.sh
index 18c3fcfb68d9..b2b0be8a0aae 100755
--- a/bin/oss-fuzz-setup.sh
+++ b/bin/oss-fuzz-setup.sh
@@ -23,7 +23,6 @@ curl --no-progress-meter -S \
-C - -O https://dev-www.libreoffice.org/src/$BOX2D_TARBALL \
-C - -O https://dev-www.libreoffice.org/src/$DTOA_TARBALL \
-C - -O https://dev-www.libreoffice.org/src/$EXPAT_TARBALL \
- -C - -O https://dev-www.libreoffice.org/src/$CUCKOO_TARBALL \
-C - -O https://dev-www.libreoffice.org/src/$LIBJPEG_TURBO_TARBALL \
-C - -O https://dev-www.libreoffice.org/src/$LCMS2_TARBALL \
-C - -O https://dev-www.libreoffice.org/src/$LIBEXTTEXTCAT_TARBALL \
diff --git a/config_host.mk.in b/config_host.mk.in
index dcc1c01c4bc4..df934f45bfc3 100644
--- a/config_host.mk.in
+++ b/config_host.mk.in
@@ -94,7 +94,6 @@ export CPPUNIT_CFLAGS=$(gb_SPACE)@CPPUNIT_CFLAGS@
export CPPUNIT_LIBS=$(gb_SPACE)@CPPUNIT_LIBS@
export CPUNAME=@CPUNAME@
export CROSS_COMPILING=@CROSS_COMPILING@
-export CUCKOO_CFLAGS=$(gb_SPACE)@CUCKOO_CFLAGS@
export CURL=@CURL@
export CURL_CFLAGS=$(gb_SPACE)@CURL_CFLAGS@
export CURL_LIBS=$(gb_SPACE)@CURL_LIBS@
@@ -593,7 +592,6 @@ export SYSTEM_BZIP2=@SYSTEM_BZIP2@
export SYSTEM_CAIRO=@SYSTEM_CAIRO@
export SYSTEM_CLUCENE=@SYSTEM_CLUCENE@
export SYSTEM_CPPUNIT=@SYSTEM_CPPUNIT@
-export SYSTEM_CUCKOO=@SYSTEM_CUCKOO@
export SYSTEM_CURL=@SYSTEM_CURL@
export SYSTEM_DICTS=@SYSTEM_DICTS@
export SYSTEM_EXPAT=@SYSTEM_EXPAT@
diff --git a/configure.ac b/configure.ac
index 85521710e9a4..e375e590193f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2376,11 +2376,6 @@ AC_ARG_WITH(system-boost,
[Use boost already on system.]),,
[with_system_boost="$with_system_headers"])
-AC_ARG_WITH(system-cuckoo,
- AS_HELP_STRING([--with-system-cuckoo],
- [Use libcuckoo already on system.]),,
- [with_system_cuckoo="$with_system_headers"])
-
AC_ARG_WITH(system-glm,
AS_HELP_STRING([--with-system-glm],
[Use glm already on system.]),,
@@ -5609,7 +5604,6 @@ if test "$cross_compiling" = "yes"; then
BOOST
CAIRO
CLUCENE
- CUCKOO
CURL
DBCONNECTIVITY
DESKTOP
@@ -10421,26 +10415,6 @@ dnl ===================================================================
libo_CHECK_SYSTEM_MODULE([mdds], [MDDS], [mdds-2.0 >= 2.0.0], ["-I${WORKDIR}/UnpackedTarball/mdds/include"])
dnl ===================================================================
-dnl Check for system cuckoo
-dnl ===================================================================
-AC_MSG_CHECKING([which cuckoo to use])
-if test "$with_system_cuckoo" = "yes"; then
- AC_MSG_RESULT([external])
- SYSTEM_CUCKOO=TRUE
- AC_LANG_PUSH([C++])
- AC_CHECK_HEADER([libcuckoo/cuckoohash_map.hh], [],
- [AC_MSG_ERROR([libcuckoo/cuckoohash_map.hh not found. install cuckoo])], [])
- AC_LANG_POP([C++])
-else
- AC_MSG_RESULT([internal])
- BUILD_TYPE="$BUILD_TYPE CUCKOO"
- SYSTEM_CUCKOO=
- CUCKOO_CFLAGS="${ISYSTEM}${WORKDIR}/UnpackedTarball/cuckoo"
-fi
-AC_SUBST([CUCKOO_CFLAGS])
-AC_SUBST([SYSTEM_CUCKOO])
-
-dnl ===================================================================
dnl Check for system glm
dnl ===================================================================
AC_MSG_CHECKING([which glm to use])
diff --git a/distro-configs/LibreOfficeCoverity.conf b/distro-configs/LibreOfficeCoverity.conf
index e802f25e8f29..51f80628701a 100644
--- a/distro-configs/LibreOfficeCoverity.conf
+++ b/distro-configs/LibreOfficeCoverity.conf
@@ -11,7 +11,6 @@
--with-idlc-cpp=cpp
--with-system-libs
--with-system-headers
---without-system-cuckoo
--without-system-cppunit
--enable-dbus
--enable-extension-integration
diff --git a/distro-configs/LibreOfficeFlatpak.conf b/distro-configs/LibreOfficeFlatpak.conf
index 438252c6c408..f6f12f776043 100644
--- a/distro-configs/LibreOfficeFlatpak.conf
+++ b/distro-configs/LibreOfficeFlatpak.conf
@@ -19,7 +19,6 @@
--without-system-clucene
--without-system-coinmp
--without-system-cppunit
---without-system-cuckoo
--without-system-firebird
--without-system-glm
--without-system-gpgmepp
diff --git a/download.lst b/download.lst
index 6ae8868c51b2..7c296335583e 100644
--- a/download.lst
+++ b/download.lst
@@ -270,5 +270,3 @@ export ZXING_TARBALL := zxing-cpp-1.2.0.tar.gz
NUMBERTEXT_EXTENSION_SHA256SUM := 1568ed1d2feb8210bb5de61d69574a165cded536cfa17c6953c9064076469de2
export OPENSYMBOL_SHA256SUM := f543e6e2d7275557a839a164941c0a86e5f2c3f2a0042bfc434c88c6dde9e140
export OPENSYMBOL_TTF := f543e6e2d7275557a839a164941c0a86e5f2c3f2a0042bfc434c88c6dde9e140-opens___.ttf
-export CUCKOO_SHA256SUM := 471dd83a813ed2816c2246c373004470ad0f6612c7ce72038929dc5161cdd58e
-export CUCKOO_TARBALL := libcuckoo-93217f8d391718380c508a722ab9acd5e9081233.tar.gz
diff --git a/external/Module_external.mk b/external/Module_external.mk
index 3de6f9cdd63f..4566d825301c 100644
--- a/external/Module_external.mk
+++ b/external/Module_external.mk
@@ -104,7 +104,6 @@ $(eval $(call gb_Module_add_moduledirs,external,\
$(call gb_Helper_optional,XSLTML,xsltml) \
$(call gb_Helper_optional,ZLIB,zlib) \
$(call gb_Helper_optional,ZMF,libzmf) \
- $(call gb_Helper_optional,CUCKOO,cuckoo) \
))
# vim: set noet sw=4 ts=4:
diff --git a/external/cuckoo/Makefile b/external/cuckoo/Makefile
deleted file mode 100644
index e4968cf85fb6..000000000000
--- a/external/cuckoo/Makefile
+++ /dev/null
@@ -1,7 +0,0 @@
-# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
-
-module_directory:=$(dir $(realpath $(firstword $(MAKEFILE_LIST))))
-
-include $(module_directory)/../../solenv/gbuild/partial_build.mk
-
-# vim: set noet sw=4 ts=4:
diff --git a/external/cuckoo/Module_cuckoo.mk b/external/cuckoo/Module_cuckoo.mk
deleted file mode 100644
index d2fda7b1e286..000000000000
--- a/external/cuckoo/Module_cuckoo.mk
+++ /dev/null
@@ -1,16 +0,0 @@
-# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
-#
-# This file is part of the LibreOffice project.
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-#
-
-$(eval $(call gb_Module_Module,cuckoo))
-
-$(eval $(call gb_Module_add_targets,cuckoo,\
- UnpackedTarball_cuckoo \
-))
-
-# vim: set noet sw=4 ts=4:
diff --git a/external/cuckoo/README b/external/cuckoo/README
deleted file mode 100644
index 6b8c98342173..000000000000
--- a/external/cuckoo/README
+++ /dev/null
@@ -1,3 +0,0 @@
-A high-performance, concurrent hash table
-
-[https://github.com/efficient/libcuckoo] \ No newline at end of file
diff --git a/external/cuckoo/UnpackedTarball_cuckoo.mk b/external/cuckoo/UnpackedTarball_cuckoo.mk
deleted file mode 100644
index e0426181b3a7..000000000000
--- a/external/cuckoo/UnpackedTarball_cuckoo.mk
+++ /dev/null
@@ -1,22 +0,0 @@
-# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
-#
-# This file is part of the LibreOffice project.
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-#
-
-$(eval $(call gb_UnpackedTarball_UnpackedTarball,cuckoo))
-
-$(eval $(call gb_UnpackedTarball_set_tarball,cuckoo,$(CUCKOO_TARBALL)))
-
-$(eval $(call gb_UnpackedTarball_set_patchlevel,cuckoo,0))
-
-$(eval $(call gb_UnpackedTarball_update_autoconf_configs,cuckoo))
-
-$(eval $(call gb_UnpackedTarball_add_patches,cuckoo,\
- external/cuckoo/cuckoo-coverity.patch \
-))
-
-# vim: set noet sw=4 ts=4:
diff --git a/external/cuckoo/cuckoo-coverity.patch b/external/cuckoo/cuckoo-coverity.patch
deleted file mode 100644
index 273d3bf1f0e3..000000000000
--- a/external/cuckoo/cuckoo-coverity.patch
+++ /dev/null
@@ -1,22 +0,0 @@
---- libcuckoo/cuckoohash_map.hh 2021-09-11 11:29:05.656553870 +0100
-+++ libcuckoo/cuckoohash_map.hh 2021-09-11 11:31:48.265203248 +0100
-@@ -866,7 +866,8 @@
-
- class TwoBuckets {
- public:
-- TwoBuckets() {}
-+ TwoBuckets()
-+ : i1(0), i2(0) {}
- TwoBuckets(size_type i1_, size_type i2_, locked_table_mode)
- : i1(i1_), i2(i2_) {}
- TwoBuckets(locks_t &locks, size_type i1_, size_type i2_, normal_mode)
-@@ -1552,7 +1553,8 @@
- " MAX_BFS_PATH_LEN - 1");
- static_assert(-1 >= std::numeric_limits<decltype(depth)>::min(),
- "The depth type must be able to hold a value of -1");
-- b_slot() {}
-+ b_slot()
-+ : bucket(0), pathcode(0), depth(0) {}
- b_slot(const size_type b, const uint16_t p, const decltype(depth) d)
- : bucket(b), pathcode(p), depth(d) {
- assert(d < MAX_BFS_PATH_LEN);
diff --git a/readlicense_oo/license/license.xml b/readlicense_oo/license/license.xml
index 0551e737f9e9..a5eab5d0dcf5 100644
--- a/readlicense_oo/license/license.xml
+++ b/readlicense_oo/license/license.xml
@@ -676,12 +676,6 @@
<p><a href="#a__LGPL_version_2">Jump to LGPL Version 2</a></p>
<p><a href="#a__MPL_version_1_1">Jump to MPL Version 1.1</a></p>
</div>
- <div class="LIBCUCKOO" >
- <h2>libcuckoo</h2>
- <p>The following software may be included in this product: libcuckoo. Use of any of this software is governed by
- the terms of the license below:</p>
- <p><a href="#a__Apache_License_version_2_0">Jump to Apache License Version 2.0</a></p>
- </div>
<div class="CURL" >
<h2>libcurl</h2>
<p>The following software may be included in this product: libcurl. Use of any of this software is governed by
diff --git a/solenv/flatpak-manifest.in b/solenv/flatpak-manifest.in
index 8733619463f1..8092f496b7d4 100644
--- a/solenv/flatpak-manifest.in
+++ b/solenv/flatpak-manifest.in
@@ -682,13 +682,6 @@
"type": "file",
"dest": "external/tarballs",
"dest-filename": "@OPENSYMBOL_TTF@"
- },
- {
- "url": "https://dev-www.libreoffice.org/src/@CUCKOO_TARBALL@",
- "sha256": "@CUCKOO_SHA256SUM@",
- "type": "file",
- "dest": "external/tarballs",
- "dest-filename": "@CUCKOO_TARBALL@"
}
],
"buildsystem": "simple",
diff --git a/svl/Library_svl.mk b/svl/Library_svl.mk
index 4e388ca0d471..6e79be4fcf06 100644
--- a/svl/Library_svl.mk
+++ b/svl/Library_svl.mk
@@ -21,7 +21,6 @@ $(eval $(call gb_Library_Library,svl))
$(eval $(call gb_Library_use_externals,svl,\
boost_headers \
- cuckoo_headers \
$(if $(filter LINUX MACOSX ANDROID iOS %BSD SOLARIS HAIKU,$(OS)), \
curl) \
dtoa \
diff --git a/svl/source/misc/sharedstringpool.cxx b/svl/source/misc/sharedstringpool.cxx
index d88b0a2c22ef..2fe8fd8a13ff 100644
--- a/svl/source/misc/sharedstringpool.cxx
+++ b/svl/source/misc/sharedstringpool.cxx
@@ -15,64 +15,50 @@
#include <unordered_map>
#include <unordered_set>
-#ifdef __GNUC__
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wshadow"
-#endif
-#if defined __clang__
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wunused-parameter"
-#endif
-#if defined _MSC_VER
-#pragma warning(push)
-#pragma warning(disable : 4324) // structure was padded due to alignment specifier
-#endif
-#include <libcuckoo/cuckoohash_map.hh>
-#if defined _MSC_VER
-#pragma warning(pop)
-#endif
-#if defined __clang__
-#pragma clang diagnostic pop
-#endif
-#ifdef __GNUC__
-#pragma GCC diagnostic pop
-#endif
-
-namespace svl
-{
+/** create a key class that caches the hashcode */
namespace
{
-sal_Int32 getRefCount(const rtl_uString* p) { return (p->refCount & 0x3FFFFFFF); }
-
-// we store the key twice, because the concurrent hashtable we are using does not provide any way to return the key in use
-typedef std::pair<OUString, OUString> Mapped;
-
-struct HashFunction
+struct StringWithHash
{
- size_t operator()(rtl_uString* const key) const
+ OUString str;
+ sal_Int32 hashCode;
+ StringWithHash(OUString s)
+ : str(s)
+ , hashCode(s.hashCode())
{
- return rtl_ustr_hashCode_WithLength(key->buffer, key->length);
}
-};
-struct EqualsFunction
-{
- bool operator()(rtl_uString* const lhs, rtl_uString* const rhs) const
+ bool operator==(StringWithHash const& rhs) const
{
- return OUString::unacquired(&lhs) == OUString::unacquired(&rhs);
+ if (hashCode != rhs.hashCode)
+ return false;
+ return str == rhs.str;
}
};
}
+namespace std
+{
+template <> struct hash<StringWithHash>
+{
+ std::size_t operator()(const StringWithHash& k) const { return k.hashCode; }
+};
+}
+
+namespace svl
+{
+namespace
+{
+sal_Int32 getRefCount(const rtl_uString* p) { return (p->refCount & 0x3FFFFFFF); }
+}
+
struct SharedStringPool::Impl
{
+ mutable std::mutex maMutex;
// We use this map for two purposes - to store lower->upper case mappings
- // and to store an upper->upper mapping.
- // The second mapping is used so that we can
- // share the same rtl_uString object between different keys which map to the same uppercase string to save memory.
- //
- // Docs for this concurrent hashtable here: http://efficient.github.io/libcuckoo/classlibcuckoo_1_1cuckoohash__map.html
- libcuckoo::cuckoohash_map<rtl_uString*, Mapped, HashFunction, EqualsFunction> maStrMap;
+ // and to retrieve a shared uppercase object, so the management logic
+ // is quite complex.
+ std::unordered_map<StringWithHash, OUString> maStrMap;
const CharClass& mrCharClass;
explicit Impl(const CharClass& rCharClass)
@@ -90,50 +76,43 @@ SharedStringPool::~SharedStringPool() {}
SharedString SharedStringPool::intern(const OUString& rStr)
{
- auto& rMap = mpImpl->maStrMap;
+ StringWithHash aStrWithHash(rStr);
+ std::scoped_lock<std::mutex> aGuard(mpImpl->maMutex);
- rtl_uString *pResultLower = {}, *pResultUpper = {}; // bogus GCC 12 -Werror=maybe-uninitialized
- if (rMap.find_fn(rStr.pData, [&](const Mapped& rMapped) {
- pResultLower = rMapped.first.pData;
- pResultUpper = rMapped.second.pData;
- }))
+ auto[mapIt, bInserted] = mpImpl->maStrMap.emplace(aStrWithHash, rStr);
+ if (!bInserted)
// there is already a mapping
- return SharedString(pResultLower, pResultUpper);
+ return SharedString(mapIt->first.str.pData, mapIt->second.pData);
// This is a new string insertion. Establish mapping to upper-case variant.
OUString aUpper = mpImpl->mrCharClass.uppercase(rStr);
-
- // either insert a new upper->upper mapping, or write the existing mapping into aUpper
- mpImpl->maStrMap.uprase_fn(aUpper.pData,
- [&](Mapped& mapped) -> bool {
- aUpper = mapped.second;
- return false;
- },
- aUpper, aUpper);
-
if (aUpper == rStr)
- // no need to do anything more, because the key is already uppercase
- return SharedString(aUpper.pData, aUpper.pData);
-
- // either insert a new lower->upper mapping, or write the existing mapping into aLower
- if (mpImpl->maStrMap.uprase_fn(rStr.pData,
- [&](Mapped& mapped) -> bool {
- pResultLower = mapped.first.pData;
- pResultUpper = mapped.second.pData;
- return false;
- },
- rStr, aUpper))
+ // no need to do anything more, because we inserted an upper->upper mapping
+ return SharedString(mapIt->first.str.pData, mapIt->second.pData);
+
+ // We need to insert a lower->upper mapping, so also insert
+ // an upper->upper mapping, which we can use both for when an upper string
+ // is interned, and to look up a shared upper string.
+ StringWithHash aUpperWithHash(aUpper);
+ auto mapIt2 = mpImpl->maStrMap.find(aUpperWithHash);
+ if (mapIt2 != mpImpl->maStrMap.end())
{
- pResultLower = rStr.pData;
- pResultUpper = aUpper.pData;
+ // there is an already existing upper string
+ mapIt->second = mapIt2->first.str;
+ return SharedString(mapIt->first.str.pData, mapIt->second.pData);
}
- return SharedString(pResultLower, pResultUpper);
+ // There is no already existing upper string.
+ // First, update using the iterator, can't do this later because
+ // the iterator will be invalid.
+ mapIt->second = aUpper;
+ mpImpl->maStrMap.emplace_hint(mapIt2, aUpperWithHash, aUpper);
+ return SharedString(rStr.pData, aUpper.pData);
}
void SharedStringPool::purge()
{
- auto locked_table = mpImpl->maStrMap.lock_table();
+ std::scoped_lock<std::mutex> aGuard(mpImpl->maMutex);
// Because we can have an uppercase entry mapped to itself,
// and then a bunch of lowercase entries mapped to that same
@@ -141,12 +120,12 @@ void SharedStringPool::purge()
// time to remove lowercase entries, and then only can we
// check for unused uppercase entries.
- auto it = locked_table.begin();
- auto itEnd = locked_table.end();
+ auto it = mpImpl->maStrMap.begin();
+ auto itEnd = mpImpl->maStrMap.end();
while (it != itEnd)
{
- rtl_uString* p1 = it->second.first.pData;
- rtl_uString* p2 = it->second.second.pData;
+ rtl_uString* p1 = it->first.str.pData;
+ rtl_uString* p2 = it->second.pData;
if (p1 != p2)
{
// normal case - lowercase mapped to uppercase, which
@@ -154,19 +133,19 @@ void SharedStringPool::purge()
// entry as the key in the map
if (getRefCount(p1) == 1)
{
- it = locked_table.erase(it);
+ it = mpImpl->maStrMap.erase(it);
continue;
}
}
++it;
}
- it = locked_table.begin();
- itEnd = locked_table.end();
+ it = mpImpl->maStrMap.begin();
+ itEnd = mpImpl->maStrMap.end();
while (it != itEnd)
{
- rtl_uString* p1 = it->second.first.pData;
- rtl_uString* p2 = it->second.second.pData;
+ rtl_uString* p1 = it->first.str.pData;
+ rtl_uString* p2 = it->second.pData;
if (p1 == p2)
{
// uppercase which is mapped to itself, which means
@@ -174,7 +153,7 @@ void SharedStringPool::purge()
// one ref-counted entry in the value in the map
if (getRefCount(p1) == 2)
{
- it = locked_table.erase(it);
+ it = mpImpl->maStrMap.erase(it);
continue;
}
}
@@ -182,15 +161,19 @@ void SharedStringPool::purge()
}
}
-size_t SharedStringPool::getCount() const { return mpImpl->maStrMap.size(); }
+size_t SharedStringPool::getCount() const
+{
+ std::scoped_lock<std::mutex> aGuard(mpImpl->maMutex);
+ return mpImpl->maStrMap.size();
+}
size_t SharedStringPool::getCountIgnoreCase() const
{
+ std::scoped_lock<std::mutex> aGuard(mpImpl->maMutex);
// this is only called from unit tests, so no need to be efficient
std::unordered_set<OUString> aUpperSet;
- auto locked_table = mpImpl->maStrMap.lock_table();
- for (auto const& pair : locked_table)
- aUpperSet.insert(pair.second.second);
+ for (auto const& pair : mpImpl->maStrMap)
+ aUpperSet.insert(pair.second);
return aUpperSet.size();
}
}