summaryrefslogtreecommitdiff
path: root/connectivity/source/inc
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2014-10-03 10:39:28 +0200
committerNoel Grandin <noelgrandin@gmail.com>2014-10-09 08:18:24 +0000
commita0a919d2b541c415ad9b81d2ee91895bf106e9bb (patch)
tree63d5c644ee8a8880d26ef6a77afb19f4e2151bdb /connectivity/source/inc
parent22a5357484f9a31a99146b738a8716a24bf59b3a (diff)
remove SvRefBase::QueryDelete
Move it's functionality into the only place that needs it, in the dbase driver. Removes an extra virtual call from a widely used class. The dbase driver seems to be using to perform some kind of whacky object recycling, so it's not like we want this functionality to be used somewhere else. Change-Id: I41018f71e0b0a79fdd3d527536f0ac95c788e614 Reviewed-on: https://gerrit.libreoffice.org/11786 Reviewed-by: Noel Grandin <noelgrandin@gmail.com> Tested-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'connectivity/source/inc')
-rw-r--r--connectivity/source/inc/dbase/dindexnode.hxx70
1 files changed, 48 insertions, 22 deletions
diff --git a/connectivity/source/inc/dbase/dindexnode.hxx b/connectivity/source/inc/dbase/dindexnode.hxx
index c59da5d299ed..791df0236efd 100644
--- a/connectivity/source/inc/dbase/dindexnode.hxx
+++ b/connectivity/source/inc/dbase/dindexnode.hxx
@@ -23,7 +23,6 @@
#include "file/FTable.hxx"
#include <connectivity/FValue.hxx>
#include <rtl/ref.hxx>
-#include <tools/ref.hxx>
#include <tools/stream.hxx>
#include <vector>
@@ -84,49 +83,53 @@ namespace connectivity
- // Index Page Pointer
-
class ONDXPage;
- typedef tools::SvRef<ONDXPage> ONDXPageRef; // Base class - because we need to store additional information
-
- class ONDXPagePtr : public ONDXPageRef
+ // Index Page Pointer
+ // This is ref-count pointer class
+ class ONDXPagePtr
{
friend SvStream& WriteONDXPagePtr(SvStream &rStream, const ONDXPagePtr&);
friend SvStream& operator >> (SvStream &rStream, ONDXPagePtr&);
+ ONDXPage* mpPage;
sal_uInt32 nPagePos; // Position in the index file
-
public:
- ONDXPagePtr(sal_uInt32 nPos = 0):nPagePos(nPos){}
+ ONDXPagePtr(sal_uInt32 nPos = 0) : mpPage(0), nPagePos(nPos) {}
ONDXPagePtr(const ONDXPagePtr& rRef);
ONDXPagePtr(ONDXPage* pRefPage);
-
- ONDXPagePtr& operator=(const ONDXPagePtr& rRef);
- ONDXPagePtr& operator=(ONDXPage* pPageRef);
+ inline ~ONDXPagePtr();
sal_uInt32 GetPagePos() const {return nPagePos;}
bool HasPage() const {return nPagePos != 0;}
- // sal_Bool Is() const { return isValid(); }
+
+ operator ONDXPage *() const { return mpPage; }
+ ONDXPage * operator ->() const { assert(mpPage != 0); return mpPage; }
+ bool Is() const { return mpPage != 0; }
+ inline void Clear();
};
// Index Page
-
- class ONDXPage : public SvRefBase
+ // This is a ref-counted class, with re-cycling
+ class ONDXPage
{
friend class ODbaseIndex;
+ friend class ONDXPagePtr;
friend SvStream& WriteONDXPage(SvStream &rStream, const ONDXPage&);
friend SvStream& operator >> (SvStream &rStream, ONDXPage&);
+ // the only reason this is not bool is because MSVC cannot handle mixed type bitfields
+ unsigned int bNoDelete : 1;
+ unsigned int nRefCount : 31;
sal_uInt32 nPagePos; // Position in the index file
- bool bModified : 1;
+ bool bModified : 1;
sal_uInt16 nCount;
- ONDXPagePtr aParent, // Parent page
- aChild; // Pointer to the right child page
- ODbaseIndex& rIndex;
- ONDXNode* ppNodes; // Array of nodes
+ ONDXPagePtr aParent, // Parent page
+ aChild; // Pointer to the right child page
+ ODbaseIndex& rIndex;
+ ONDXNode* ppNodes; // Array of nodes
public:
// Node operations
@@ -174,9 +177,22 @@ namespace connectivity
protected:
ONDXPage(ODbaseIndex& rIndex, sal_uInt32 nPos, ONDXPage* = NULL);
- virtual ~ONDXPage();
-
- virtual void QueryDelete() SAL_OVERRIDE;
+ ~ONDXPage();
+
+ void ReleaseRef();
+ void QueryDelete();
+ void AddNextRef()
+ {
+ assert( nRefCount < (1 << 30) && "Do not add refs to dead objects" );
+ ++nRefCount;
+ }
+ void AddFirstRef()
+ {
+ assert( nRefCount < (1 << 30) && "Do not add refs to dead objects" );
+ if( bNoDelete )
+ bNoDelete = 0;
+ ++nRefCount;
+ }
void SetModified(bool bMod) {bModified = bMod;}
void SetPagePos(sal_uInt32 nPage) {nPagePos = nPage;}
@@ -189,6 +205,16 @@ namespace connectivity
#endif
};
+ inline ONDXPagePtr::~ONDXPagePtr() { if (mpPage != 0) mpPage->ReleaseRef(); }
+ inline void ONDXPagePtr::Clear()
+ {
+ if (mpPage != 0) {
+ ONDXPage * pRefObj = mpPage;
+ mpPage = 0;
+ pRefObj->ReleaseRef();
+ }
+ }
+
SvStream& WriteONDXPagePtr(SvStream &rStream, const ONDXPagePtr&);
SvStream& operator >> (SvStream &rStream, ONDXPagePtr&);