svl/source/misc/sharedstringpool.cxx |   15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)

New commits:
commit e715619d3b28292b751860f01c853f59720b285d
Author:     Noel Grandin <noelgran...@gmail.com>
AuthorDate: Sun Aug 5 13:39:50 2018 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Mon Aug 6 10:17:17 2018 +0200

    simplify SharedStringPool and assert invariants
    
    Change-Id: I7385db9e87f8a8f7a4be1f7c52e770e8afcb3a23
    Reviewed-on: https://gerrit.libreoffice.org/58615
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/svl/source/misc/sharedstringpool.cxx 
b/svl/source/misc/sharedstringpool.cxx
index 76b4403c954b..64993497957b 100644
--- a/svl/source/misc/sharedstringpool.cxx
+++ b/svl/source/misc/sharedstringpool.cxx
@@ -36,10 +36,7 @@ InsertResultType findOrInsert( StrHashType& rPool, const 
OUString& rStr )
     {
         // Not yet in the pool.
         std::pair<StrHashType::iterator, bool> r = rPool.insert(rStr);
-        if (!r.second)
-            // Insertion failed.
-            return InsertResultType(rPool.end(), false);
-
+        assert(r.second);
         it = r.first;
         bInserted = true;
     }
@@ -72,9 +69,6 @@ SharedString SharedStringPool::intern( const OUString& rStr )
     osl::MutexGuard aGuard(&mpImpl->maMutex);
 
     InsertResultType aRes = findOrInsert(mpImpl->maStrPool, rStr);
-    if (aRes.first == mpImpl->maStrPool.end())
-        // Insertion failed.
-        return SharedString();
 
     rtl_uString* pOrig = aRes.first->pData;
 
@@ -86,8 +80,7 @@ SharedString SharedStringPool::intern( const OUString& rStr )
     {
         // No new string has been inserted. Return the existing string in the 
pool.
         StrStoreType::const_iterator it = mpImpl->maStrStore.find(pOrig);
-        if (it == mpImpl->maStrStore.end())
-            return SharedString();
+        assert(it != mpImpl->maStrStore.end());
 
         rtl_uString* pUpper = it->second.pData;
         return SharedString(pOrig, pUpper);
@@ -97,9 +90,7 @@ SharedString SharedStringPool::intern( const OUString& rStr )
 
     OUString aUpper = mpImpl->mpCharClass->uppercase(rStr);
     aRes = findOrInsert(mpImpl->maStrPoolUpper, aUpper);
-    if (aRes.first == mpImpl->maStrPoolUpper.end())
-        // Failed to insert or fetch upper-case variant. Should never happen.
-        return SharedString();
+    assert(aRes.first != mpImpl->maStrPoolUpper.end());
 
     mpImpl->maStrStore.emplace(pOrig, *aRes.first);
 
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to