diff options
Diffstat (limited to 'sot')
-rw-r--r-- | sot/source/sdstor/stgcache.cxx | 39 | ||||
-rw-r--r-- | sot/source/sdstor/stgcache.hxx | 12 |
2 files changed, 15 insertions, 36 deletions
diff --git a/sot/source/sdstor/stgcache.cxx b/sot/source/sdstor/stgcache.cxx index fc2c8778e5d8..74094f8b65a8 100644 --- a/sot/source/sdstor/stgcache.cxx +++ b/sot/source/sdstor/stgcache.cxx @@ -18,14 +18,6 @@ */ -#if defined(_MSC_VER) && (_MSC_VER<1200) -#include <tools/presys.h> -#endif -#include <boost/unordered_map.hpp> -#if defined(_MSC_VER) && (_MSC_VER<1200) -#include <tools/postsys.h> -#endif - #include <string.h> #include <osl/endian.h> #include <tools/string.hxx> @@ -37,19 +29,6 @@ #include "stgdir.hxx" #include "stgio.hxx" -/*************************************************************************/ -//----------------------------------------------------------------------------- -typedef boost::unordered_map -< - sal_Int32, - StgPage *, - boost::hash< sal_Int32 >, - std::equal_to< sal_Int32 > -> UsrStgPagePtr_Impl; -#ifdef _MSC_VER -#pragma warning( disable: 4786 ) -#endif - //#define CHECK_DIRTY 1 //#define READ_AFTER_WRITE 1 @@ -110,7 +89,6 @@ StgCache::StgCache() nError = SVSTREAM_OK; bMyStream = sal_False; bFile = sal_False; - pLRUCache = NULL; pStorageStream = NULL; } @@ -118,7 +96,6 @@ StgCache::~StgCache() { Clear(); SetStrm( NULL, sal_False ); - delete (UsrStgPagePtr_Impl*)pLRUCache; } void StgCache::SetPhysPageSize( short n ) @@ -154,9 +131,7 @@ StgPage* StgCache::Create( sal_Int32 nPg ) } else pElem->pNext1 = pElem->pLast1 = pElem; - if( !pLRUCache ) - pLRUCache = new UsrStgPagePtr_Impl(); - (*(UsrStgPagePtr_Impl*)pLRUCache)[pElem->nPage] = pElem; + maLRUCache[pElem->nPage] = pElem; pCur = pElem; // insert to Sorted @@ -194,8 +169,7 @@ void StgCache::Erase( StgPage* pElem ) pElem->pLast1->pNext1 = pElem->pNext1; if( pCur == pElem ) pCur = ( pElem->pNext1 == pElem ) ? NULL : pElem->pNext1; - if( pLRUCache ) - ((UsrStgPagePtr_Impl*)pLRUCache)->erase( pElem->nPage ); + maLRUCache.erase( pElem->nPage ); // remove from Sorted pElem->pNext2->pLast2 = pElem->pLast2; pElem->pLast2->pNext2 = pElem->pNext2; @@ -219,18 +193,15 @@ void StgCache::Clear() while( pCur != pElem ); pCur = NULL; pElem1 = NULL; - delete (UsrStgPagePtr_Impl*)pLRUCache; - pLRUCache = NULL; + maLRUCache.clear(); } // Look for a cached page StgPage* StgCache::Find( sal_Int32 nPage ) { - if( !pLRUCache ) - return NULL; - UsrStgPagePtr_Impl::iterator aIt = ((UsrStgPagePtr_Impl*)pLRUCache)->find( nPage ); - if( aIt != ((UsrStgPagePtr_Impl*)pLRUCache)->end() ) + IndexToStgPage::iterator aIt = maLRUCache.find( nPage ); + if( aIt != maLRUCache.end() ) { // page found StgPage* pFound = (*aIt).second; diff --git a/sot/source/sdstor/stgcache.hxx b/sot/source/sdstor/stgcache.hxx index a9fcc85fa1a5..34204231b7d3 100644 --- a/sot/source/sdstor/stgcache.hxx +++ b/sot/source/sdstor/stgcache.hxx @@ -24,20 +24,28 @@ #include <tools/solar.h> #include <tools/stream.hxx> #include <stgelem.hxx> +#include <boost/unordered_map.hpp> class UCBStorageStream; - class StgPage; class StgDirEntry; class StorageBase; +typedef boost::unordered_map +< + sal_Int32, + StgPage *, + boost::hash< sal_Int32 >, + std::equal_to< sal_Int32 > +> IndexToStgPage; + class StgCache { StgPage* pCur; // top of LRU list StgPage* pElem1; // top of ordered list sal_uLong nError; // error code sal_Int32 nPages; // size of data area in pages sal_uInt16 nRef; // reference count - void * pLRUCache; // hash table of cached objects + IndexToStgPage maLRUCache; // hash of index to cached pages short nPageSize; // page size of the file UCBStorageStream* pStorageStream; // holds reference to UCB storage stream |