Kaydet (Commit) e715619d authored tarafından Noel Grandin's avatar Noel Grandin Kaydeden (comit) Noel Grandin

simplify SharedStringPool and assert invariants

Change-Id: I7385db9e87f8a8f7a4be1f7c52e770e8afcb3a23
Reviewed-on: https://gerrit.libreoffice.org/58615
Tested-by: Jenkins
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 61a54ea6
...@@ -36,10 +36,7 @@ InsertResultType findOrInsert( StrHashType& rPool, const OUString& rStr ) ...@@ -36,10 +36,7 @@ InsertResultType findOrInsert( StrHashType& rPool, const OUString& rStr )
{ {
// Not yet in the pool. // Not yet in the pool.
std::pair<StrHashType::iterator, bool> r = rPool.insert(rStr); std::pair<StrHashType::iterator, bool> r = rPool.insert(rStr);
if (!r.second) assert(r.second);
// Insertion failed.
return InsertResultType(rPool.end(), false);
it = r.first; it = r.first;
bInserted = true; bInserted = true;
} }
...@@ -72,9 +69,6 @@ SharedString SharedStringPool::intern( const OUString& rStr ) ...@@ -72,9 +69,6 @@ SharedString SharedStringPool::intern( const OUString& rStr )
osl::MutexGuard aGuard(&mpImpl->maMutex); osl::MutexGuard aGuard(&mpImpl->maMutex);
InsertResultType aRes = findOrInsert(mpImpl->maStrPool, rStr); InsertResultType aRes = findOrInsert(mpImpl->maStrPool, rStr);
if (aRes.first == mpImpl->maStrPool.end())
// Insertion failed.
return SharedString();
rtl_uString* pOrig = aRes.first->pData; rtl_uString* pOrig = aRes.first->pData;
...@@ -86,8 +80,7 @@ SharedString SharedStringPool::intern( const OUString& rStr ) ...@@ -86,8 +80,7 @@ SharedString SharedStringPool::intern( const OUString& rStr )
{ {
// No new string has been inserted. Return the existing string in the pool. // No new string has been inserted. Return the existing string in the pool.
StrStoreType::const_iterator it = mpImpl->maStrStore.find(pOrig); StrStoreType::const_iterator it = mpImpl->maStrStore.find(pOrig);
if (it == mpImpl->maStrStore.end()) assert(it != mpImpl->maStrStore.end());
return SharedString();
rtl_uString* pUpper = it->second.pData; rtl_uString* pUpper = it->second.pData;
return SharedString(pOrig, pUpper); return SharedString(pOrig, pUpper);
...@@ -97,9 +90,7 @@ SharedString SharedStringPool::intern( const OUString& rStr ) ...@@ -97,9 +90,7 @@ SharedString SharedStringPool::intern( const OUString& rStr )
OUString aUpper = mpImpl->mpCharClass->uppercase(rStr); OUString aUpper = mpImpl->mpCharClass->uppercase(rStr);
aRes = findOrInsert(mpImpl->maStrPoolUpper, aUpper); aRes = findOrInsert(mpImpl->maStrPoolUpper, aUpper);
if (aRes.first == mpImpl->maStrPoolUpper.end()) assert(aRes.first != mpImpl->maStrPoolUpper.end());
// Failed to insert or fetch upper-case variant. Should never happen.
return SharedString();
mpImpl->maStrStore.emplace(pOrig, *aRes.first); mpImpl->maStrStore.emplace(pOrig, *aRes.first);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment