summaryrefslogtreecommitdiff
path: root/svl/qa
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2020-05-30 10:46:41 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-06-02 15:32:26 +0200
commit3581f1d71ae0d431ba28c0f3b7b263ff6212ce7b (patch)
tree25233be9e519e16170606aea72a6b2aaaedc3e2e /svl/qa
parent413791a65597a1808d9b98e4887864f3624b70cc (diff)
optimize SharedStringPool::purge() and fix tests
which were checking the wrong thing - we don't care about the input strings to intern(), we care about which SharedString objects are still alive. Change-Id: Ia35a173a02a24efb335268dcae4078a956d11098 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95177 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'svl/qa')
-rw-r--r--svl/qa/unit/svl.cxx15
1 files changed, 6 insertions, 9 deletions
diff --git a/svl/qa/unit/svl.cxx b/svl/qa/unit/svl.cxx
index 488cc04ecde7..6b44a96729d1 100644
--- a/svl/qa/unit/svl.cxx
+++ b/svl/qa/unit/svl.cxx
@@ -36,6 +36,7 @@
#include <unotools/syslocale.hxx>
#include <memory>
+#include <optional>
#include <unicode/timezone.h>
using namespace ::com::sun::star;
@@ -371,15 +372,11 @@ void Test::testSharedStringPoolPurge()
CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), aPool.getCount());
CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), aPool.getCountIgnoreCase());
- // Now, create string objects on the heap.
- std::unique_ptr<OUString> pStr1(new OUString("Andy"));
- std::unique_ptr<OUString> pStr2(new OUString("andy"));
- std::unique_ptr<OUString> pStr3(new OUString("ANDY"));
- std::unique_ptr<OUString> pStr4(new OUString("Bruce"));
- aPool.intern(*pStr1);
- aPool.intern(*pStr2);
- aPool.intern(*pStr3);
- aPool.intern(*pStr4);
+ // Now, create string objects using optional so we can clear them
+ std::optional<svl::SharedString> pStr1 = aPool.intern("Andy");
+ std::optional<svl::SharedString> pStr2 = aPool.intern("andy");
+ std::optional<svl::SharedString> pStr3 = aPool.intern("ANDY");
+ std::optional<svl::SharedString> pStr4 = aPool.intern("Bruce");
CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(4), aPool.getCount());
CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), aPool.getCountIgnoreCase());