Kaydet (Commit) 77f88406 authored tarafından Noel Grandin's avatar Noel Grandin

loplugin:mergeclasses

Change-Id: I14985f98989861d74b3904ab79f3ced5a3d96f73
üst 44a46d4f
...@@ -249,7 +249,6 @@ merge slideshow::internal::UserPaintEventHandler with slideshow::internal::Paint ...@@ -249,7 +249,6 @@ merge slideshow::internal::UserPaintEventHandler with slideshow::internal::Paint
merge slideshow::internal::View with slideshow::internal::UnoView merge slideshow::internal::View with slideshow::internal::UnoView
merge slideshow::internal::ViewRepaintHandler with (anonymous namespace)::SlideShowImpl::SeparateListenerImpl merge slideshow::internal::ViewRepaintHandler with (anonymous namespace)::SlideShowImpl::SeparateListenerImpl
merge slideshow::internal::ViewUpdate with slideshow::internal::ShapeManagerImpl merge slideshow::internal::ViewUpdate with slideshow::internal::ShapeManagerImpl
merge store::PageCache with store::PageCache_Impl
merge svgio::svgreader::InfoProvider with svgio::svgreader::SvgNode merge svgio::svgreader::InfoProvider with svgio::svgreader::SvgNode
merge svl::IUndoManager with SfxUndoManager merge svl::IUndoManager with SfxUndoManager
merge svl::StyleSheetCallback with (anonymous namespace)::AddStyleSheetCallback merge svl::StyleSheetCallback with (anonymous namespace)::AddStyleSheetCallback
......
...@@ -37,69 +37,9 @@ ...@@ -37,69 +37,9 @@
using namespace store; using namespace store;
// PageCache (non-virtual interface) implementation.
storeError PageCache::lookupPageAt (PageHolder & rxPage, sal_uInt32 nOffset)
{
OSL_PRECOND(!(nOffset == STORE_PAGE_NULL), "store::PageCache::lookupPageAt(): invalid Offset");
if (nOffset == STORE_PAGE_NULL)
return store_E_CantSeek;
return lookupPageAt_Impl (rxPage, nOffset);
}
storeError PageCache::insertPageAt (PageHolder const & rxPage, sal_uInt32 nOffset)
{
// [SECURITY:ValInput]
PageData const * pagedata = rxPage.get();
OSL_PRECOND(!(pagedata == 0), "store::PageCache::insertPageAt(): invalid Page");
if (pagedata == 0)
return store_E_InvalidParameter;
sal_uInt32 const offset = pagedata->location();
OSL_PRECOND(!(nOffset != offset), "store::PageCache::insertPageAt(): inconsistent Offset");
if (nOffset != offset)
return store_E_InvalidParameter;
OSL_PRECOND(!(nOffset == STORE_PAGE_NULL), "store::PageCache::insertPageAt(): invalid Offset");
if (nOffset == STORE_PAGE_NULL)
return store_E_CantSeek;
return insertPageAt_Impl (rxPage, nOffset);
}
storeError PageCache::updatePageAt (PageHolder const & rxPage, sal_uInt32 nOffset)
{
// [SECURITY:ValInput]
PageData const * pagedata = rxPage.get();
OSL_PRECOND(!(pagedata == 0), "store::PageCache::updatePageAt(): invalid Page");
if (pagedata == 0)
return store_E_InvalidParameter;
sal_uInt32 const offset = pagedata->location();
OSL_PRECOND(!(nOffset != offset), "store::PageCache::updatePageAt(): inconsistent Offset");
if (nOffset != offset)
return store_E_InvalidParameter;
OSL_PRECOND(!(nOffset == STORE_PAGE_NULL), "store::PageCache::updatePageAt(): invalid Offset");
if (nOffset == STORE_PAGE_NULL)
return store_E_CantSeek;
return updatePageAt_Impl (rxPage, nOffset);
}
storeError PageCache::removePageAt (sal_uInt32 nOffset)
{
OSL_PRECOND(!(nOffset == STORE_PAGE_NULL), "store::PageCache::removePageAt(): invalid Offset");
if (nOffset == STORE_PAGE_NULL)
return store_E_CantSeek;
return removePageAt_Impl (nOffset);
}
// Entry // Entry
namespace
{
namespace store {
struct Entry struct Entry
{ {
// Representation // Representation
...@@ -119,8 +59,7 @@ struct Entry ...@@ -119,8 +59,7 @@ struct Entry
// Destruction // Destruction
~Entry() {} ~Entry() {}
}; };
};
} // namespace
// EntryCache interface // EntryCache interface
namespace namespace
...@@ -219,69 +158,8 @@ static int highbit(sal_Size n) ...@@ -219,69 +158,8 @@ static int highbit(sal_Size n)
return k; return k;
} }
//PageCache_Impl implementation
namespace store
{
class PageCache_Impl :
public store::OStoreObject,
public store::PageCache,
private boost::noncopyable
{
// Representation
static size_t const theTableSize = 32;
static_assert(STORE_IMPL_ISP2(theTableSize), "must be the case");
Entry ** m_hash_table; PageCache::PageCache (sal_uInt16 nPageSize)
Entry * m_hash_table_0[theTableSize];
size_t m_hash_size;
size_t m_hash_shift;
size_t const m_page_shift;
size_t m_hash_entries; // total number of entries in table.
size_t m_nHit;
size_t m_nMissed;
static inline int hash_Impl(sal_uInt32 a, size_t s, size_t q, size_t m)
{
return static_cast<int>((((a) + ((a) >> (s)) + ((a) >> ((s) << 1))) >> (q)) & (m));
}
inline int hash_index_Impl (sal_uInt32 nOffset)
{
return hash_Impl(nOffset, m_hash_shift, m_page_shift, m_hash_size - 1);
}
Entry * lookup_Impl (Entry * entry, sal_uInt32 nOffset);
void rescale_Impl (sal_Size new_size);
// PageCache Implementation
virtual storeError lookupPageAt_Impl (
PageHolder & rxPage,
sal_uInt32 nOffset) SAL_OVERRIDE;
virtual storeError insertPageAt_Impl (
PageHolder const & rxPage,
sal_uInt32 nOffset) SAL_OVERRIDE;
virtual storeError updatePageAt_Impl (
PageHolder const & rxPage,
sal_uInt32 nOffset) SAL_OVERRIDE;
virtual storeError removePageAt_Impl (
sal_uInt32 nOffset) SAL_OVERRIDE;
public:
// Construction
explicit PageCache_Impl (sal_uInt16 nPageSize);
protected:
// Destruction
virtual ~PageCache_Impl();
};
} // namespace store
PageCache_Impl::PageCache_Impl (sal_uInt16 nPageSize)
: m_hash_table (m_hash_table_0), : m_hash_table (m_hash_table_0),
m_hash_size (theTableSize), m_hash_size (theTableSize),
m_hash_shift (highbit(m_hash_size) - 1), m_hash_shift (highbit(m_hash_size) - 1),
...@@ -295,7 +173,7 @@ PageCache_Impl::PageCache_Impl (sal_uInt16 nPageSize) ...@@ -295,7 +173,7 @@ PageCache_Impl::PageCache_Impl (sal_uInt16 nPageSize)
memset(m_hash_table_0, 0, sizeof(m_hash_table_0)); memset(m_hash_table_0, 0, sizeof(m_hash_table_0));
} }
PageCache_Impl::~PageCache_Impl() PageCache::~PageCache()
{ {
double s_x = 0.0; double s_x = 0.0;
sal_Size i, n = m_hash_size; sal_Size i, n = m_hash_size;
...@@ -326,7 +204,7 @@ PageCache_Impl::~PageCache_Impl() ...@@ -326,7 +204,7 @@ PageCache_Impl::~PageCache_Impl()
OSL_TRACE("Hits: %zu, Misses: %zu", m_nHit, m_nMissed); OSL_TRACE("Hits: %zu, Misses: %zu", m_nHit, m_nMissed);
} }
void PageCache_Impl::rescale_Impl (sal_Size new_size) void PageCache::rescale_Impl (sal_Size new_size)
{ {
sal_Size new_bytes = new_size * sizeof(Entry*); sal_Size new_bytes = new_size * sizeof(Entry*);
Entry ** new_table = static_cast<Entry**>(rtl_allocateMemory(new_bytes)); Entry ** new_table = static_cast<Entry**>(rtl_allocateMemory(new_bytes));
...@@ -369,7 +247,7 @@ void PageCache_Impl::rescale_Impl (sal_Size new_size) ...@@ -369,7 +247,7 @@ void PageCache_Impl::rescale_Impl (sal_Size new_size)
} }
} }
Entry * PageCache_Impl::lookup_Impl (Entry * entry, sal_uInt32 nOffset) Entry * PageCache::lookup_Impl (Entry * entry, sal_uInt32 nOffset)
{ {
int lookups = 0; int lookups = 0;
while (entry != 0) while (entry != 0)
...@@ -391,10 +269,12 @@ Entry * PageCache_Impl::lookup_Impl (Entry * entry, sal_uInt32 nOffset) ...@@ -391,10 +269,12 @@ Entry * PageCache_Impl::lookup_Impl (Entry * entry, sal_uInt32 nOffset)
return entry; return entry;
} }
storeError PageCache_Impl::lookupPageAt_Impl ( storeError PageCache::lookupPageAt (PageHolder & rxPage, sal_uInt32 nOffset)
PageHolder & rxPage,
sal_uInt32 nOffset)
{ {
OSL_PRECOND(!(nOffset == STORE_PAGE_NULL), "store::PageCache::lookupPageAt(): invalid Offset");
if (nOffset == STORE_PAGE_NULL)
return store_E_CantSeek;
int index = hash_index_Impl(nOffset); int index = hash_index_Impl(nOffset);
Entry const * entry = lookup_Impl (m_hash_table[index], nOffset); Entry const * entry = lookup_Impl (m_hash_table[index], nOffset);
if (entry != 0) if (entry != 0)
...@@ -412,10 +292,23 @@ storeError PageCache_Impl::lookupPageAt_Impl ( ...@@ -412,10 +292,23 @@ storeError PageCache_Impl::lookupPageAt_Impl (
return store_E_NotExists; return store_E_NotExists;
} }
storeError PageCache_Impl::insertPageAt_Impl ( storeError PageCache::insertPageAt (PageHolder const & rxPage, sal_uInt32 nOffset)
PageHolder const & rxPage,
sal_uInt32 nOffset)
{ {
// [SECURITY:ValInput]
PageData const * pagedata = rxPage.get();
OSL_PRECOND(!(pagedata == 0), "store::PageCache::insertPageAt(): invalid Page");
if (pagedata == 0)
return store_E_InvalidParameter;
sal_uInt32 const offset = pagedata->location();
OSL_PRECOND(!(nOffset != offset), "store::PageCache::insertPageAt(): inconsistent Offset");
if (nOffset != offset)
return store_E_InvalidParameter;
OSL_PRECOND(!(nOffset == STORE_PAGE_NULL), "store::PageCache::insertPageAt(): invalid Offset");
if (nOffset == STORE_PAGE_NULL)
return store_E_CantSeek;
Entry * entry = EntryCache::get().create (rxPage, nOffset); Entry * entry = EntryCache::get().create (rxPage, nOffset);
if (entry != 0) if (entry != 0)
{ {
...@@ -430,10 +323,23 @@ storeError PageCache_Impl::insertPageAt_Impl ( ...@@ -430,10 +323,23 @@ storeError PageCache_Impl::insertPageAt_Impl (
return store_E_OutOfMemory; return store_E_OutOfMemory;
} }
storeError PageCache_Impl::updatePageAt_Impl ( storeError PageCache::updatePageAt (PageHolder const & rxPage, sal_uInt32 nOffset)
PageHolder const & rxPage,
sal_uInt32 nOffset)
{ {
// [SECURITY:ValInput]
PageData const * pagedata = rxPage.get();
OSL_PRECOND(!(pagedata == 0), "store::PageCache::updatePageAt(): invalid Page");
if (pagedata == 0)
return store_E_InvalidParameter;
sal_uInt32 const offset = pagedata->location();
OSL_PRECOND(!(nOffset != offset), "store::PageCache::updatePageAt(): inconsistent Offset");
if (nOffset != offset)
return store_E_InvalidParameter;
OSL_PRECOND(!(nOffset == STORE_PAGE_NULL), "store::PageCache::updatePageAt(): invalid Offset");
if (nOffset == STORE_PAGE_NULL)
return store_E_CantSeek;
int index = hash_index_Impl(nOffset); int index = hash_index_Impl(nOffset);
Entry * entry = lookup_Impl (m_hash_table[index], nOffset); Entry * entry = lookup_Impl (m_hash_table[index], nOffset);
if (entry != 0) if (entry != 0)
...@@ -444,12 +350,15 @@ storeError PageCache_Impl::updatePageAt_Impl ( ...@@ -444,12 +350,15 @@ storeError PageCache_Impl::updatePageAt_Impl (
// Update stats and leave. // m_nUpdHit += 1; // Update stats and leave. // m_nUpdHit += 1;
return store_E_None; return store_E_None;
} }
return insertPageAt_Impl (rxPage, nOffset); return insertPageAt (rxPage, nOffset);
} }
storeError PageCache_Impl::removePageAt_Impl ( storeError PageCache::removePageAt (sal_uInt32 nOffset)
sal_uInt32 nOffset)
{ {
OSL_PRECOND(!(nOffset == STORE_PAGE_NULL), "store::PageCache::removePageAt(): invalid Offset");
if (nOffset == STORE_PAGE_NULL)
return store_E_CantSeek;
Entry ** ppEntry = &(m_hash_table[hash_index_Impl(nOffset)]); Entry ** ppEntry = &(m_hash_table[hash_index_Impl(nOffset)]);
while (*ppEntry != 0) while (*ppEntry != 0)
{ {
...@@ -492,7 +401,7 @@ PageCache_createInstance ( ...@@ -492,7 +401,7 @@ PageCache_createInstance (
rtl::Reference< store::PageCache > & rxCache, rtl::Reference< store::PageCache > & rxCache,
sal_uInt16 nPageSize) sal_uInt16 nPageSize)
{ {
rxCache = new PageCache_Impl (nPageSize); rxCache = new PageCache (nPageSize);
if (!rxCache.is()) if (!rxCache.is())
return store_E_OutOfMemory; return store_E_OutOfMemory;
......
...@@ -25,19 +25,54 @@ ...@@ -25,19 +25,54 @@
#include "store/types.h" #include "store/types.h"
#include "storbase.hxx" #include "storbase.hxx"
#include "object.hxx"
#include "boost/noncopyable.hpp"
namespace store namespace store
{ {
struct Entry;
/*======================================================================== /*========================================================================
* *
* PageCache interface. * PageCache interface.
* *
*======================================================================*/ *======================================================================*/
class PageCache : public virtual salhelper::SimpleReferenceObject class PageCache :
public store::OStoreObject,
private boost::noncopyable
{ {
// Representation
static size_t const theTableSize = 32;
static_assert(STORE_IMPL_ISP2(theTableSize), "must be the case");
Entry ** m_hash_table;
Entry * m_hash_table_0[theTableSize];
size_t m_hash_size;
size_t m_hash_shift;
size_t const m_page_shift;
size_t m_hash_entries; // total number of entries in table.
size_t m_nHit;
size_t m_nMissed;
static inline int hash_Impl(sal_uInt32 a, size_t s, size_t q, size_t m)
{
return static_cast<int>((((a) + ((a) >> (s)) + ((a) >> ((s) << 1))) >> (q)) & (m));
}
inline int hash_index_Impl (sal_uInt32 nOffset)
{
return hash_Impl(nOffset, m_hash_shift, m_page_shift, m_hash_size - 1);
}
Entry * lookup_Impl (Entry * entry, sal_uInt32 nOffset);
void rescale_Impl (sal_Size new_size);
public: public:
// Construction
explicit PageCache (sal_uInt16 nPageSize);
/** load. /** load.
*/ */
storeError lookupPageAt ( storeError lookupPageAt (
...@@ -62,25 +97,8 @@ public: ...@@ -62,25 +97,8 @@ public:
sal_uInt32 nOffset); sal_uInt32 nOffset);
protected: protected:
virtual ~PageCache() {} // Destruction
virtual ~PageCache();
private:
/** Implementation (abstract).
*/
virtual storeError lookupPageAt_Impl (
PageHolder & rxPage,
sal_uInt32 nOffset) = 0;
virtual storeError insertPageAt_Impl (
PageHolder const & rxPage,
sal_uInt32 nOffset) = 0;
virtual storeError updatePageAt_Impl (
PageHolder const & rxPage,
sal_uInt32 nOffset) = 0;
virtual storeError removePageAt_Impl (
sal_uInt32 nOffset) = 0;
}; };
/*======================================================================== /*========================================================================
......
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