summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2021-12-05 22:59:31 +0100
committerLuboš Luňák <l.lunak@collabora.com>2021-12-06 12:22:49 +0100
commita4c9664532329d7143aabdacf22b1cab662f77c4 (patch)
tree8bc3d0c27a334bb5486d039a9768a34fd2424eab
parent0ca559cb8cc3b1af6c59066713bbed8e3ee76514 (diff)
make it clearer that ScHint is modified
It's somewhat confusing that an accessor is provided to give a reference to internal data and then the object is modified indirectly using the reference. It appears to be only for performance reasons, so I thought that inlining the ctor and ctor could help the compiler to optimize this, but apparently it can't move this outside of the loop, so at least make it clearer. Change-Id: I72cf15d1446daa559ac4079b9478e53694d7d198 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126394 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
-rw-r--r--include/svl/hint.hxx2
-rw-r--r--sc/Library_sc.mk1
-rw-r--r--sc/inc/brdcst.hxx6
-rw-r--r--sc/inc/column.hxx2
-rw-r--r--sc/inc/table.hxx2
-rw-r--r--sc/source/core/data/bcaslot.cxx7
-rw-r--r--sc/source/core/data/column.cxx23
-rw-r--r--sc/source/core/data/column3.cxx2
-rw-r--r--sc/source/core/data/documen7.cxx4
-rw-r--r--sc/source/core/data/table2.cxx5
-rw-r--r--sc/source/core/tool/brdcst.cxx25
-rw-r--r--svl/Library_svl.mk1
-rw-r--r--svl/source/notify/hint.cxx26
13 files changed, 23 insertions, 83 deletions
diff --git a/include/svl/hint.hxx b/include/svl/hint.hxx
index 337930335a0f..ef1343a49fc8 100644
--- a/include/svl/hint.hxx
+++ b/include/svl/hint.hxx
@@ -213,7 +213,7 @@ private:
public:
SfxHint() : mnId(SfxHintId::NONE) {}
explicit SfxHint( SfxHintId nId ) : mnId(nId) {}
- virtual ~SfxHint() COVERITY_NOEXCEPT_FALSE;
+ virtual ~SfxHint() {};
SfxHint(SfxHint const &) = default;
SfxHint(SfxHint &&) = default;
diff --git a/sc/Library_sc.mk b/sc/Library_sc.mk
index ddcd76fac4f2..f71517536338 100644
--- a/sc/Library_sc.mk
+++ b/sc/Library_sc.mk
@@ -207,7 +207,6 @@ $(eval $(call gb_Library_add_exception_objects,sc,\
sc/source/core/tool/adiasync \
sc/source/core/tool/appoptio \
sc/source/core/tool/autoform \
- sc/source/core/tool/brdcst \
sc/source/core/tool/calcconfig \
sc/source/core/tool/callform \
sc/source/core/tool/cellform \
diff --git a/sc/inc/brdcst.hxx b/sc/inc/brdcst.hxx
index 0c29d29e607a..3d57e7644370 100644
--- a/sc/inc/brdcst.hxx
+++ b/sc/inc/brdcst.hxx
@@ -26,9 +26,11 @@ class ScHint final : public SfxHint
ScAddress aAddress;
public:
- ScHint( SfxHintId n, const ScAddress& a );
+ ScHint( SfxHintId n, const ScAddress& a ) : SfxHint(n), aAddress(a) {}
const ScAddress& GetAddress() const { return aAddress; }
- ScAddress& GetAddress() { return aAddress; }
+ void SetAddressTab(SCTAB nTab) { aAddress.SetTab(nTab); }
+ void SetAddressCol(SCCOL nCol) { aAddress.SetCol(nCol); }
+ void SetAddressRow(SCROW nRow) { aAddress.SetRow(nRow); }
};
class ScAreaChangedHint final : public SfxHint
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 91e5b5c3fc22..384c12d52248 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -414,7 +414,7 @@ public:
@param rHint address is modified to adapt to the actual broadcasted
position on each iteration and upon return points to the last
position broadcasted. */
- bool BroadcastBroadcasters( SCROW nRow1, SCROW nRow2, ScHint& rHint );
+ bool BroadcastBroadcasters( SCROW nRow1, SCROW nRow2, SfxHintId nHint );
bool CompileErrorCells( sc::CompileFormulaContext& rCxt, FormulaError nErrCode );
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index 672d8431dfe4..fa8d6326d479 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -650,7 +650,7 @@ public:
@param rHint address is modified to adapt to the actual broadcasted
position on each iteration and upon return points to the last
position broadcasted. */
- bool BroadcastBroadcasters( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScHint& rHint );
+ bool BroadcastBroadcasters( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, SfxHintId nHint );
bool CompileErrorCells( sc::CompileFormulaContext& rCxt, FormulaError nErrCode );
diff --git a/sc/source/core/data/bcaslot.cxx b/sc/source/core/data/bcaslot.cxx
index 03a031be7943..ad8609ecdee0 100644
--- a/sc/source/core/data/bcaslot.cxx
+++ b/sc/source/core/data/bcaslot.cxx
@@ -213,16 +213,15 @@ namespace {
void broadcastRangeByCell( SvtBroadcaster& rBC, const ScRange& rRange, SfxHintId nHint )
{
ScHint aHint(nHint, ScAddress());
- ScAddress& rPos = aHint.GetAddress();
for (SCTAB nTab = rRange.aStart.Tab(); nTab <= rRange.aEnd.Tab(); ++nTab)
{
- rPos.SetTab(nTab);
+ aHint.SetAddressTab(nTab);
for (SCCOL nCol = rRange.aStart.Col(); nCol <= rRange.aEnd.Col(); ++nCol)
{
- rPos.SetCol(nCol);
+ aHint.SetAddressCol(nCol);
for (SCROW nRow = rRange.aStart.Row(); nRow <= rRange.aEnd.Row(); ++nRow)
{
- rPos.SetRow(nRow);
+ aHint.SetAddressRow(nRow);
rBC.Broadcast(aHint);
}
}
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index 63ab1886ffff..482ce0b2a1a8 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -2041,12 +2041,11 @@ void ScColumn::MoveTo(SCROW nStartRow, SCROW nEndRow, ScColumn& rCol)
// Broadcast on moved ranges. Area-broadcast only.
ScDocument& rDocument = GetDoc();
ScHint aHint(SfxHintId::ScDataChanged, ScAddress(nCol, 0, nTab));
- ScAddress& rPos = aHint.GetAddress();
for (const auto& rRange : aRanges)
{
for (SCROW nRow = rRange.mnRow1; nRow <= rRange.mnRow2; ++nRow)
{
- rPos.SetRow(nRow);
+ aHint.SetAddressRow(nRow);
rDocument.AreaBroadcast(aHint);
}
}
@@ -3262,22 +3261,20 @@ namespace {
class BroadcastBroadcastersHandler
{
- ScHint& mrHint;
- ScAddress& mrAddress;
+ ScHint maHint;
bool mbBroadcasted;
public:
- explicit BroadcastBroadcastersHandler( ScHint& rHint )
- : mrHint(rHint)
- , mrAddress(mrHint.GetAddress())
+ explicit BroadcastBroadcastersHandler( SfxHintId nHint, SCTAB nTab, SCCOL nCol )
+ : maHint(nHint, ScAddress(nCol, 0, nTab))
, mbBroadcasted(false)
{
}
void operator() ( size_t nRow, SvtBroadcaster* pBroadcaster )
{
- mrAddress.SetRow(nRow);
- pBroadcaster->Broadcast(mrHint);
+ maHint.SetAddressRow(nRow);
+ pBroadcaster->Broadcast(maHint);
mbBroadcasted = true;
}
@@ -3286,10 +3283,9 @@ public:
}
-bool ScColumn::BroadcastBroadcasters( SCROW nRow1, SCROW nRow2, ScHint& rHint )
+bool ScColumn::BroadcastBroadcasters( SCROW nRow1, SCROW nRow2, SfxHintId nHint )
{
- rHint.GetAddress().SetCol(nCol);
- BroadcastBroadcastersHandler aBroadcasterHdl( rHint);
+ BroadcastBroadcastersHandler aBroadcasterHdl(nHint, nTab, nCol);
sc::ProcessBroadcaster(maBroadcasters.begin(), maBroadcasters, nRow1, nRow2, aBroadcasterHdl);
return aBroadcasterHdl.wasBroadcasted();
}
@@ -3322,8 +3318,7 @@ void ScColumn::SetDirty( SCROW nRow1, SCROW nRow2, BroadcastMode eMode )
SetDirtyOnRangeHandler aHdl(*this);
sc::ProcessFormula(maCells.begin(), maCells, nRow1, nRow2, aHdl);
// Broadcast all broadcasters in range.
- ScHint aHint( SfxHintId::ScDataChanged, ScAddress( nCol, nRow1, nTab));
- if (BroadcastBroadcasters( nRow1, nRow2, aHint))
+ if (BroadcastBroadcasters( nRow1, nRow2, SfxHintId::ScDataChanged))
{
// SetDirtyOnRangeHandler implicitly tracks notified
// formulas via ScDocument::Broadcast(), which
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 8361018c41c8..dfdd4e59e1bc 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -86,7 +86,7 @@ void ScColumn::BroadcastCells( const std::vector<SCROW>& rRows, SfxHintId nHint
ScHint aHint(nHint, ScAddress(nCol, 0, nTab));
for (const auto& rRow : rRows)
{
- aHint.GetAddress().SetRow(rRow);
+ aHint.SetAddressRow(rRow);
rDocument.Broadcast(aHint);
}
}
diff --git a/sc/source/core/data/documen7.cxx b/sc/source/core/data/documen7.cxx
index dbbbbcae7883..ab6ae63cb549 100644
--- a/sc/source/core/data/documen7.cxx
+++ b/sc/source/core/data/documen7.cxx
@@ -161,15 +161,13 @@ void ScDocument::BroadcastCells( const ScRange& rRange, SfxHintId nHint, bool bB
if (bBroadcastSingleBroadcasters)
{
- ScHint aHint(nHint, ScAddress());
-
for (SCTAB nTab = nTab1; nTab <= nTab2; ++nTab)
{
ScTable* pTab = FetchTable(nTab);
if (!pTab)
continue;
- bIsBroadcasted |= pTab->BroadcastBroadcasters( nCol1, nRow1, nCol2, nRow2, aHint);
+ bIsBroadcasted |= pTab->BroadcastBroadcasters( nCol1, nRow1, nCol2, nRow2, nHint);
}
}
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index b3250ff08f31..8e1cbf009032 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -2067,14 +2067,13 @@ void ScTable::BroadcastRecalcOnRefMove()
aCol[i].BroadcastRecalcOnRefMove();
}
-bool ScTable::BroadcastBroadcasters( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScHint& rHint )
+bool ScTable::BroadcastBroadcasters( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, SfxHintId nHint )
{
bool bBroadcasted = false;
sc::AutoCalcSwitch aSwitch(rDocument, false);
- rHint.GetAddress().SetTab(nTab);
nCol2 = ClampToAllocatedColumns(nCol2);
for (SCCOL nCol = nCol1; nCol <= nCol2; ++nCol)
- bBroadcasted |= aCol[nCol].BroadcastBroadcasters( nRow1, nRow2, rHint);
+ bBroadcasted |= aCol[nCol].BroadcastBroadcasters( nRow1, nRow2, nHint);
return bBroadcasted;
}
diff --git a/sc/source/core/tool/brdcst.cxx b/sc/source/core/tool/brdcst.cxx
deleted file mode 100644
index bf852b36335e..000000000000
--- a/sc/source/core/tool/brdcst.cxx
+++ /dev/null
@@ -1,25 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#include <brdcst.hxx>
-
-ScHint::ScHint( SfxHintId n, const ScAddress& a ) :
- SfxHint(n), aAddress(a) {}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svl/Library_svl.mk b/svl/Library_svl.mk
index b81660089ea0..4e388ca0d471 100644
--- a/svl/Library_svl.mk
+++ b/svl/Library_svl.mk
@@ -168,7 +168,6 @@ $(eval $(call gb_Library_add_exception_objects,svl,\
svl/source/misc/urihelper \
svl/source/notify/SfxBroadcaster \
svl/source/notify/broadcast \
- svl/source/notify/hint \
svl/source/notify/isethint \
svl/source/notify/listener \
svl/source/notify/lstner \
diff --git a/svl/source/notify/hint.cxx b/svl/source/notify/hint.cxx
deleted file mode 100644
index 72cac43ef9a9..000000000000
--- a/svl/source/notify/hint.cxx
+++ /dev/null
@@ -1,26 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#include <svl/hint.hxx>
-
-// virtual dtor for the typical base-class Hint
-
-SfxHint::~SfxHint() COVERITY_NOEXCEPT_FALSE {}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */