Kaydet (Commit) 09d5b31e authored tarafından Noel Grandin's avatar Noel Grandin

loplugin:constantfunction: store

Change-Id: I13284409404ef77eb16164b7ce2074259d2cad12
üst 5eeec136
...@@ -751,9 +751,7 @@ public: ...@@ -751,9 +751,7 @@ public:
return store_E_InvalidAccess; return store_E_InvalidAccess;
pHead->guard(nAddr); pHead->guard(nAddr);
T * pImpl = dynamic_page_cast<T>(pHead); OSL_PRECOND(dynamic_page_cast<T>(pHead) != 0, "store::PageHolder<T>::guard(): Null pointer");
OSL_PRECOND(pImpl != 0, "store::PageHolder<T>::guard(): Null pointer");
pImpl->guard();
return store_E_None; return store_E_None;
} }
...@@ -771,7 +769,7 @@ public: ...@@ -771,7 +769,7 @@ public:
if (!pImpl) if (!pImpl)
return store_E_WrongVersion; return store_E_WrongVersion;
return pImpl->verify(); return store_E_None;
} }
}; };
......
...@@ -594,7 +594,7 @@ OStoreDirectoryPageObject::scope ( ...@@ -594,7 +594,7 @@ OStoreDirectoryPageObject::scope (
sal_uInt32 index0, index1, index2, index3; sal_uInt32 index0, index1, index2, index3;
// direct. // direct.
sal_uInt32 nCount = OStoreDirectoryDataBlock::directCount(); sal_uInt32 nCount = OStoreDirectoryDataBlock::directCount;
sal_uInt32 nLimit = nCount; sal_uInt32 nLimit = nCount;
if (nPage < nLimit) if (nPage < nLimit)
{ {
...@@ -611,7 +611,7 @@ OStoreDirectoryPageObject::scope ( ...@@ -611,7 +611,7 @@ OStoreDirectoryPageObject::scope (
// single indirect. // single indirect.
sal_uInt32 const nCapacity = indirect::capacityCount(rPage.m_aDescr); sal_uInt32 const nCapacity = indirect::capacityCount(rPage.m_aDescr);
nCount = OStoreDirectoryDataBlock::singleCount(); nCount = OStoreDirectoryDataBlock::singleCount;
nLimit = nCount * nCapacity; nLimit = nCount * nCapacity;
if (nPage < nLimit) if (nPage < nLimit)
{ {
...@@ -640,7 +640,7 @@ OStoreDirectoryPageObject::scope ( ...@@ -640,7 +640,7 @@ OStoreDirectoryPageObject::scope (
nPage -= nLimit; nPage -= nLimit;
// double indirect. // double indirect.
nCount = OStoreDirectoryDataBlock::doubleCount(); nCount = OStoreDirectoryDataBlock::doubleCount;
nLimit = nCount * nCapacity * nCapacity; nLimit = nCount * nCapacity * nCapacity;
if (nPage < nLimit) if (nPage < nLimit)
{ {
...@@ -675,7 +675,7 @@ OStoreDirectoryPageObject::scope ( ...@@ -675,7 +675,7 @@ OStoreDirectoryPageObject::scope (
nPage -= nLimit; nPage -= nLimit;
// triple indirect. // triple indirect.
nCount = OStoreDirectoryDataBlock::tripleCount(); nCount = OStoreDirectoryDataBlock::tripleCount;
nLimit = nCount * nCapacity * nCapacity * nCapacity; nLimit = nCount * nCapacity * nCapacity * nCapacity;
if (nPage < nLimit) if (nPage < nLimit)
{ {
...@@ -1016,7 +1016,7 @@ storeError OStoreDirectoryPageObject::truncate ( ...@@ -1016,7 +1016,7 @@ storeError OStoreDirectoryPageObject::truncate (
if (eScope == page::SCOPE_DIRECT) if (eScope == page::SCOPE_DIRECT)
{ {
// Truncate direct data pages. // Truncate direct data pages.
sal_uInt16 i, n = OStoreDirectoryDataBlock::directCount(); sal_uInt16 i, n = OStoreDirectoryDataBlock::directCount;
for (i = n; i > nRemain; i--) for (i = n; i > nRemain; i--)
{ {
// Obtain data page location. // Obtain data page location.
...@@ -1039,7 +1039,7 @@ storeError OStoreDirectoryPageObject::truncate ( ...@@ -1039,7 +1039,7 @@ storeError OStoreDirectoryPageObject::truncate (
if (eScope == page::SCOPE_SINGLE) if (eScope == page::SCOPE_SINGLE)
{ {
// Truncate single indirect pages. // Truncate single indirect pages.
sal_uInt16 i, n = OStoreDirectoryDataBlock::singleCount(); sal_uInt16 i, n = OStoreDirectoryDataBlock::singleCount;
for (i = n; i > nRemain; i--) for (i = n; i > nRemain; i--)
{ {
// Truncate single indirect page to zero data pages. // Truncate single indirect page to zero data pages.
...@@ -1058,7 +1058,7 @@ storeError OStoreDirectoryPageObject::truncate ( ...@@ -1058,7 +1058,7 @@ storeError OStoreDirectoryPageObject::truncate (
if (eScope == page::SCOPE_DOUBLE) if (eScope == page::SCOPE_DOUBLE)
{ {
// Truncate double indirect pages. // Truncate double indirect pages.
sal_uInt16 i, n = OStoreDirectoryDataBlock::doubleCount(); sal_uInt16 i, n = OStoreDirectoryDataBlock::doubleCount;
for (i = n; i > nRemain; i--) for (i = n; i > nRemain; i--)
{ {
// Truncate double indirect page to zero single indirect pages. // Truncate double indirect page to zero single indirect pages.
...@@ -1077,7 +1077,7 @@ storeError OStoreDirectoryPageObject::truncate ( ...@@ -1077,7 +1077,7 @@ storeError OStoreDirectoryPageObject::truncate (
if (eScope == page::SCOPE_TRIPLE) if (eScope == page::SCOPE_TRIPLE)
{ {
// Truncate triple indirect pages. // Truncate triple indirect pages.
sal_uInt16 i, n = OStoreDirectoryDataBlock::tripleCount(); sal_uInt16 i, n = OStoreDirectoryDataBlock::tripleCount;
for (i = n; i > nRemain; i--) for (i = n; i > nRemain; i--)
{ {
// Truncate to zero double indirect pages. // Truncate to zero double indirect pages.
......
...@@ -87,13 +87,6 @@ struct OStoreDataPageData : public store::OStorePageData ...@@ -87,13 +87,6 @@ struct OStoreDataPageData : public store::OStorePageData
if (capacity()) memset (m_pData, 0, capacity()); if (capacity()) memset (m_pData, 0, capacity());
} }
/** guard (external representation).
*/
void guard() {}
/** verify (external representation).
*/
storeError verify() const { return store_E_None; }
}; };
/*======================================================================== /*========================================================================
...@@ -467,77 +460,69 @@ struct OStoreDirectoryDataBlock ...@@ -467,77 +460,69 @@ struct OStoreDirectoryDataBlock
/** direct. /** direct.
*/ */
static sal_uInt16 directCount (void) static const sal_uInt16 directCount = ((sal_uInt16)(STORE_LIMIT_DATAPAGE_DIRECT));
{
return ((sal_uInt16)(STORE_LIMIT_DATAPAGE_DIRECT));
}
sal_uInt32 directLink (sal_uInt16 nIndex) const sal_uInt32 directLink (sal_uInt16 nIndex) const
{ {
if (nIndex < directCount()) if (nIndex < directCount)
return store::ntohl(m_aTable.m_pDirect[nIndex]); return store::ntohl(m_aTable.m_pDirect[nIndex]);
else else
return STORE_PAGE_NULL; return STORE_PAGE_NULL;
} }
void directLink (sal_uInt16 nIndex, sal_uInt32 nAddr) void directLink (sal_uInt16 nIndex, sal_uInt32 nAddr)
{ {
if (nIndex < directCount()) if (nIndex < directCount)
m_aTable.m_pDirect[nIndex] = store::htonl(nAddr); m_aTable.m_pDirect[nIndex] = store::htonl(nAddr);
} }
/** single. /** single.
*/ */
static sal_uInt16 singleCount (void) static const sal_uInt16 singleCount = ((sal_uInt16)(STORE_LIMIT_DATAPAGE_SINGLE));
{
return ((sal_uInt16)(STORE_LIMIT_DATAPAGE_SINGLE));
}
sal_uInt32 singleLink (sal_uInt16 nIndex) const sal_uInt32 singleLink (sal_uInt16 nIndex) const
{ {
if (nIndex < singleCount()) if (nIndex < singleCount)
return store::ntohl(m_aTable.m_pSingle[nIndex]); return store::ntohl(m_aTable.m_pSingle[nIndex]);
else else
return STORE_PAGE_NULL; return STORE_PAGE_NULL;
} }
void singleLink (sal_uInt16 nIndex, sal_uInt32 nAddr) void singleLink (sal_uInt16 nIndex, sal_uInt32 nAddr)
{ {
if (nIndex < singleCount()) if (nIndex < singleCount)
m_aTable.m_pSingle[nIndex] = store::htonl(nAddr); m_aTable.m_pSingle[nIndex] = store::htonl(nAddr);
} }
/** double. /** double.
*/ */
static sal_uInt16 doubleCount (void) static const sal_uInt16 doubleCount = ((sal_uInt16)(STORE_LIMIT_DATAPAGE_DOUBLE));
{
return ((sal_uInt16)(STORE_LIMIT_DATAPAGE_DOUBLE));
}
sal_uInt32 doubleLink (sal_uInt16 nIndex) const sal_uInt32 doubleLink (sal_uInt16 nIndex) const
{ {
if (nIndex < doubleCount()) if (nIndex < doubleCount)
return store::ntohl(m_aTable.m_pDouble[nIndex]); return store::ntohl(m_aTable.m_pDouble[nIndex]);
else else
return STORE_PAGE_NULL; return STORE_PAGE_NULL;
} }
void doubleLink (sal_uInt16 nIndex, sal_uInt32 nAddr) void doubleLink (sal_uInt16 nIndex, sal_uInt32 nAddr)
{ {
if (nIndex < doubleCount()) if (nIndex < doubleCount)
m_aTable.m_pDouble[nIndex] = store::htonl(nAddr); m_aTable.m_pDouble[nIndex] = store::htonl(nAddr);
} }
/** triple. /** triple.
*/ */
static sal_uInt16 tripleCount (void) static const sal_uInt16 tripleCount = ((sal_uInt16)(STORE_LIMIT_DATAPAGE_TRIPLE));
{
return ((sal_uInt16)(STORE_LIMIT_DATAPAGE_TRIPLE));
}
sal_uInt32 tripleLink (sal_uInt16 nIndex) const sal_uInt32 tripleLink (sal_uInt16 nIndex) const
{ {
if (nIndex < tripleCount()) if (nIndex < tripleCount)
return store::ntohl(m_aTable.m_pTriple[nIndex]); return store::ntohl(m_aTable.m_pTriple[nIndex]);
else else
return STORE_PAGE_NULL; return STORE_PAGE_NULL;
} }
void tripleLink (sal_uInt16 nIndex, sal_uInt32 nAddr) void tripleLink (sal_uInt16 nIndex, sal_uInt32 nAddr)
{ {
if (nIndex < tripleCount()) if (nIndex < tripleCount)
m_aTable.m_pTriple[nIndex] = store::htonl(nAddr); m_aTable.m_pTriple[nIndex] = store::htonl(nAddr);
} }
}; };
......
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