summaryrefslogtreecommitdiff
path: root/sw/source/core/SwNumberTree
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2017-07-06 14:13:12 +0200
committerMichael Stahl <mstahl@redhat.com>2017-07-06 23:29:43 +0200
commitea3e718855d804943831db81428fec249b9c7575 (patch)
tree64bedd0026b0598a7b24c4eae7cd2aa3e677fef5 /sw/source/core/SwNumberTree
parenta0dc0d3cc2cf64567eeebba73d308f6ad827d810 (diff)
sw: convert SwNumberTree::IsSane to assert() and simplify
Change-Id: Ib2087a53d2a22f5fdafa5c3d0d058dd0ad8ed643
Diffstat (limited to 'sw/source/core/SwNumberTree')
-rw-r--r--sw/source/core/SwNumberTree/SwNumberTree.cxx72
1 files changed, 24 insertions, 48 deletions
diff --git a/sw/source/core/SwNumberTree/SwNumberTree.cxx b/sw/source/core/SwNumberTree/SwNumberTree.cxx
index f60f0c0a732b..c606f7b34aea 100644
--- a/sw/source/core/SwNumberTree/SwNumberTree.cxx
+++ b/sw/source/core/SwNumberTree/SwNumberTree.cxx
@@ -23,6 +23,8 @@
#include <osl/diagnose.h>
#include <sal/log.hxx>
+#include <cassert>
+
using std::vector;
using std::find;
@@ -385,7 +387,8 @@ void SwNumberTreeNode::MoveGreaterChildren( SwNumberTreeNode& _rCompareNode,
}
#ifdef DBG_UTIL
- SAL_WARN_IF(!IsSane(false) || !_rDestNode.IsSane(true), "sw.core", "insanity");
+ IsSane(false);
+ _rDestNode.IsSane(true);
#endif
}
@@ -433,7 +436,8 @@ void SwNumberTreeNode::MoveChildren(SwNumberTreeNode * pDest)
OSL_ENSURE(mChildren.empty(), "MoveChildren failed!");
#ifdef DBG_UTIL
- OSL_ENSURE(IsSane(false) && pDest->IsSane(false), "insanity!");
+ IsSane(false);
+ pDest->IsSane(false);
#endif
}
@@ -585,7 +589,7 @@ void SwNumberTreeNode::AddChild( SwNumberTreeNode * pChild,
}
#ifdef DBG_UTIL
- SAL_WARN_IF(!IsSane(false), "sw.core", "insanity");
+ IsSane(false);
#endif
}
@@ -678,7 +682,7 @@ void SwNumberTreeNode::RemoveMe()
pSavedParent->ClearObsoletePhantoms();
#ifdef DBG_UTIL
- SAL_WARN_IF(!IsSane(false), "sw.core", "insanity");
+ IsSane(false);
#endif
}
}
@@ -857,34 +861,22 @@ SwNumberTreeNode::GetChildCount() const
}
#ifdef DBG_UTIL
-bool SwNumberTreeNode::IsSane(bool bRecursive) const
+void SwNumberTreeNode::IsSane(bool bRecursive) const
{
vector<const SwNumberTreeNode*> aParents;
return IsSane(bRecursive, aParents);
}
-bool SwNumberTreeNode::IsSane(bool bRecursive,
+void SwNumberTreeNode::IsSane(bool bRecursive,
vector<const SwNumberTreeNode *> rParents)
const
{
- bool bResult = true;
-
tSwNumberTreeChildren::const_iterator aIt;
- if (find(rParents.begin(), rParents.end(), this) != rParents.end())
- {
- OSL_FAIL(" I'm my own ancestor!");
-
- bResult = false;
- }
+ assert(find(rParents.begin(), rParents.end(), this) == rParents.end());
- if (! rParents.empty() && rParents.back() != mpParent)
- {
- OSL_FAIL(" I'm a bastard!");
-
- bResult = false;
- }
+ assert(rParents.empty() || rParents.back() == mpParent);
rParents.push_back(this);
@@ -895,49 +887,33 @@ bool SwNumberTreeNode::IsSane(bool bRecursive,
{
if ((*aIt)->IsPhantom())
{
- if ((*aIt)->HasOnlyPhantoms())
- {
- bResult = false;
- }
+ SAL_WARN_IF((*aIt)->HasOnlyPhantoms(), "sw.core",
+ "HasOnlyPhantoms: is this an error?");
- if (! bFirst)
- {
- OSL_FAIL(" found phantom not at first position.");
-
- bResult = false;
- }
+ assert(bFirst && "found phantom not at first position.");
}
- if ((*aIt)->mpParent != (SwNumberTreeNode *) this)
- {
- OSL_FAIL("found a bastard");
-
- bResult = false;
- }
+ assert((*aIt)->mpParent == this);
if (mpParent)
{
- if (!(*aIt)->IsPhantom() && (*aIt)->LessThan(*this))
- {
- OSL_FAIL(" found child less than me");
-
- bResult = false;
- }
+ assert((*aIt)->IsPhantom() || !(*aIt)->LessThan(*this));
}
}
else
{
- OSL_FAIL("found child that is NULL");
- bResult = false;
+ assert(!"found child that is NULL");
}
- if (bRecursive)
- bResult = (*aIt)->IsSane(bRecursive, rParents) && bResult;
+ if (bRecursive)
+ {
+ (*aIt)->IsSane(bRecursive, rParents);
+ }
+
+ bFirst = false;
}
rParents.pop_back();
-
- return bResult;
}
#endif // DBG_UTIL