summaryrefslogtreecommitdiff
path: root/sw/source/core
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2021-05-30 09:35:42 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-05-31 10:46:58 +0200
commitc7f484eb774fc90cf8e1540a703c5c3856312ef2 (patch)
tree46f4b98c8ab60fe95a5cadc910823362c3d3c235 /sw/source/core
parent8371ae143ef31c332bdcf753ca1dff722a531229 (diff)
no need to allocate this separately
std: :vector is only 3 words big in it's empty state Change-Id: I5d7630f0ded1ace284c0a4441230bf672f4639be Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116398 Tested-by: Noel Grandin <noel.grandin@collabora.co.uk> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw/source/core')
-rw-r--r--sw/source/core/doc/doclay.cxx6
-rw-r--r--sw/source/core/docnode/node.cxx19
-rw-r--r--sw/source/core/edit/autofmt.cxx5
-rw-r--r--sw/source/core/layout/atrfrm.cxx15
-rw-r--r--sw/source/core/layout/frmtool.cxx14
-rw-r--r--sw/source/core/layout/wsfrm.cxx16
-rw-r--r--sw/source/core/txtnode/ndtxt.cxx6
7 files changed, 28 insertions, 53 deletions
diff --git a/sw/source/core/doc/doclay.cxx b/sw/source/core/doc/doclay.cxx
index 43b4408ec080..556ff77fdb78 100644
--- a/sw/source/core/doc/doclay.cxx
+++ b/sw/source/core/doc/doclay.cxx
@@ -1571,11 +1571,11 @@ bool SwDoc::IsInHeaderFooter( const SwNodeIndex& rIdx ) const
checkFormats.push_back( pFormat );
}
#endif
- std::vector<SwFrameFormat*> const*const pFlys(pFlyNd->GetAnchoredFlys());
+ std::vector<SwFrameFormat*> const & rFlys(pFlyNd->GetAnchoredFlys());
bool bFound(false);
- for (size_t i = 0; pFlys && i < pFlys->size(); ++i)
+ for (size_t i = 0; i < rFlys.size(); ++i)
{
- const SwFrameFormat *const pFormat = (*pFlys)[i];
+ const SwFrameFormat *const pFormat = rFlys[i];
const SwNodeIndex* pIdx = pFormat->GetContent().GetContentIdx();
if( pIdx && pFlyNd == &pIdx->GetNode() )
{
diff --git a/sw/source/core/docnode/node.cxx b/sw/source/core/docnode/node.cxx
index 3b0245969246..4f7b18ba3a68 100644
--- a/sw/source/core/docnode/node.cxx
+++ b/sw/source/core/docnode/node.cxx
@@ -347,7 +347,7 @@ SwNode::SwNode( SwNodes& rNodes, sal_uLong nPos, const SwNodeType nNdType )
SwNode::~SwNode()
{
- assert(!m_xAnchoredFlys || GetDoc().IsInDtor()); // must all be deleted
+ assert(m_aAnchoredFlys.empty() || GetDoc().IsInDtor()); // must all be deleted
InvalidateInSwCache(RES_OBJECTDYING);
assert(!IsInCache());
}
@@ -2119,11 +2119,7 @@ void SwNode::AddAnchoredFly(SwFrameFormat *const pFlyFormat)
assert(&pFlyFormat->GetAnchor(false).GetContentAnchor()->nNode.GetNode() == this);
// check node type, cf. SwFormatAnchor::SetAnchor()
assert(IsTextNode() || IsStartNode() || IsTableNode());
- if (!m_xAnchoredFlys)
- {
- m_xAnchoredFlys.emplace();
- }
- m_xAnchoredFlys->push_back(pFlyFormat);
+ m_aAnchoredFlys.push_back(pFlyFormat);
}
void SwNode::RemoveAnchoredFly(SwFrameFormat *const pFlyFormat)
@@ -2132,14 +2128,9 @@ void SwNode::RemoveAnchoredFly(SwFrameFormat *const pFlyFormat)
// cannot assert this in Remove because it is called when new anchor is already set
// assert(&pFlyFormat->GetAnchor(false).GetContentAnchor()->nNode.GetNode() == this);
assert(IsTextNode() || IsStartNode() || IsTableNode());
- assert(m_xAnchoredFlys);
- auto it(std::find(m_xAnchoredFlys->begin(), m_xAnchoredFlys->end(), pFlyFormat));
- assert(it != m_xAnchoredFlys->end());
- m_xAnchoredFlys->erase(it);
- if (m_xAnchoredFlys->empty())
- {
- m_xAnchoredFlys.reset();
- }
+ auto it(std::find(m_aAnchoredFlys.begin(), m_aAnchoredFlys.end(), pFlyFormat));
+ assert(it != m_aAnchoredFlys.end());
+ m_aAnchoredFlys.erase(it);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/edit/autofmt.cxx b/sw/source/core/edit/autofmt.cxx
index b9b4d8480a7a..12df8e7383e9 100644
--- a/sw/source/core/edit/autofmt.cxx
+++ b/sw/source/core/edit/autofmt.cxx
@@ -345,11 +345,8 @@ bool SwAutoFormat::HasObjects(const SwTextFrame & rFrame)
SwNodeIndex node(*rFrame.GetTextNodeFirst());
do
{
- if (node.GetNode().GetAnchoredFlys() != nullptr)
- {
- assert(!node.GetNode().GetAnchoredFlys()->empty());
+ if (!node.GetNode().GetAnchoredFlys().empty())
return true;
- }
++node;
}
while (sw::FrameContainsNode(rFrame, node.GetIndex()));
diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx
index dd434fb6d90c..fc4865619466 100644
--- a/sw/source/core/layout/atrfrm.cxx
+++ b/sw/source/core/layout/atrfrm.cxx
@@ -3582,14 +3582,11 @@ void CheckAnchoredFlyConsistency(SwDoc const& rDoc)
for (sal_uLong i = 0; i != count; ++i)
{
SwNode const*const pNode(rNodes[i]);
- std::vector<SwFrameFormat*> const*const pFlys(pNode->GetAnchoredFlys());
- if (pFlys)
+ std::vector<SwFrameFormat*> const & rFlys(pNode->GetAnchoredFlys());
+ for (const auto& rpFly : rFlys)
{
- for (const auto& rpFly : *pFlys)
- {
- SwFormatAnchor const& rAnchor((*rpFly).GetAnchor(false));
- assert(&rAnchor.GetContentAnchor()->nNode.GetNode() == pNode);
- }
+ SwFormatAnchor const& rAnchor((*rpFly).GetAnchor(false));
+ assert(&rAnchor.GetContentAnchor()->nNode.GetNode() == pNode);
}
}
SwFrameFormats const*const pSpzFrameFormats(rDoc.GetSpzFrameFormats());
@@ -3609,8 +3606,8 @@ void CheckAnchoredFlyConsistency(SwDoc const& rDoc)
else
{
SwNode & rNode(rAnchor.GetContentAnchor()->nNode.GetNode());
- std::vector<SwFrameFormat*> const*const pFlys(rNode.GetAnchoredFlys());
- assert(std::find(pFlys->begin(), pFlys->end(), *it) != pFlys->end());
+ std::vector<SwFrameFormat*> const& rFlys(rNode.GetAnchoredFlys());
+ assert(std::find(rFlys.begin(), rFlys.end(), *it) != rFlys.end());
switch (rAnchor.GetAnchorId())
{
case RndStdIds::FLY_AT_FLY:
diff --git a/sw/source/core/layout/frmtool.cxx b/sw/source/core/layout/frmtool.cxx
index 51e76b63daaa..13350fef27c3 100644
--- a/sw/source/core/layout/frmtool.cxx
+++ b/sw/source/core/layout/frmtool.cxx
@@ -1160,12 +1160,8 @@ void RemoveHiddenObjsOfNode(SwTextNode const& rNode,
std::vector<sw::Extent>::const_iterator const*const pEnd,
SwTextNode const*const pFirstNode, SwTextNode const*const pLastNode)
{
- std::vector<SwFrameFormat*> const*const pFlys(rNode.GetAnchoredFlys());
- if (!pFlys)
- {
- return;
- }
- for (SwFrameFormat * pFrameFormat : *pFlys)
+ std::vector<SwFrameFormat*> const & rFlys(rNode.GetAnchoredFlys());
+ for (SwFrameFormat * pFrameFormat : rFlys)
{
SwFormatAnchor const& rAnchor = pFrameFormat->GetAnchor();
if (rAnchor.GetAnchorId() == RndStdIds::FLY_AT_CHAR
@@ -1204,10 +1200,10 @@ void AppendObjsOfNode(SwFrameFormats const*const pTable, sal_uLong const nIndex,
#endif
SwNode const& rNode(*pDoc->GetNodes()[nIndex]);
- std::vector<SwFrameFormat*> const*const pFlys(rNode.GetAnchoredFlys());
- for (size_t it = 0; pFlys && it != pFlys->size(); )
+ std::vector<SwFrameFormat*> const & rFlys(rNode.GetAnchoredFlys());
+ for (size_t it = 0; it != rFlys.size(); )
{
- SwFrameFormat *const pFormat = (*pFlys)[it];
+ SwFrameFormat *const pFormat = rFlys[it];
const SwFormatAnchor &rAnch = pFormat->GetAnchor();
if ( rAnch.GetContentAnchor() &&
IsShown(nIndex, rAnch, pIter, pEnd, pFirstNode, pLastNode))
diff --git a/sw/source/core/layout/wsfrm.cxx b/sw/source/core/layout/wsfrm.cxx
index 27c9c6f5049d..4e8fb2e1fa1f 100644
--- a/sw/source/core/layout/wsfrm.cxx
+++ b/sw/source/core/layout/wsfrm.cxx
@@ -4240,14 +4240,11 @@ static void AddRemoveFlysForNode(
if (pSkipped)
{
// if a fly has been added by AppendObjsOfNode, it must be skipped; if not, then it doesn't matter if it's skipped or not because it has no frames and because of that it would be skipped anyway
- if (auto const pFlys = pNode->GetAnchoredFlys())
+ for (auto const pFly : pNode->GetAnchoredFlys())
{
- for (auto const pFly : *pFlys)
+ if (pFly->Which() != RES_DRAWFRMFMT)
{
- if (pFly->Which() != RES_DRAWFRMFMT)
- {
- pSkipped->insert(pFly->GetContent().GetContentIdx()->GetIndex());
- }
+ pSkipped->insert(pFly->GetContent().GetContentIdx()->GetIndex());
}
}
}
@@ -4418,12 +4415,9 @@ static void UnHideRedlines(SwRootFrame & rLayout,
{
sw::RemoveFootnotesForNode(rLayout, *pNode->GetTextNode(), nullptr);
// similarly, remove the anchored flys
- if (auto const pFlys = pNode->GetAnchoredFlys())
+ for (SwFrameFormat * pFormat : pNode->GetAnchoredFlys())
{
- for (SwFrameFormat * pFormat : *pFlys)
- {
- pFormat->DelFrames(/*&rLayout*/);
- }
+ pFormat->DelFrames(/*&rLayout*/);
}
}
}
diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx
index d513fe97c267..1a21120cb05c 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -1447,10 +1447,10 @@ void SwTextNode::Update(
}
}
#endif
- std::vector<SwFrameFormat*> const*const pFlys(GetAnchoredFlys());
- for (size_t i = 0; pFlys && i != pFlys->size(); ++i)
+ std::vector<SwFrameFormat*> const& rFlys(GetAnchoredFlys());
+ for (size_t i = 0; i != rFlys.size(); ++i)
{
- SwFrameFormat const*const pFormat = (*pFlys)[i];
+ SwFrameFormat const*const pFormat = rFlys[i];
const SwFormatAnchor& rAnchor = pFormat->GetAnchor();
const SwPosition* pContentAnchor = rAnchor.GetContentAnchor();
if (rAnchor.GetAnchorId() == RndStdIds::FLY_AT_CHAR && pContentAnchor)