[Libreoffice-commits] core.git: include/svl sc/inc sc/source svl/source

2022-05-06 Thread Daniel Kamil Kozar (via logerrit)
 include/svl/numformat.hxx|2 +-
 sc/inc/cellform.hxx  |7 ---
 sc/inc/column.hxx|   10 +-
 sc/inc/document.hxx  |2 +-
 sc/inc/table.hxx |2 +-
 sc/source/core/data/column3.cxx  |4 ++--
 sc/source/core/data/document.cxx |4 ++--
 sc/source/core/data/table2.cxx   |4 ++--
 sc/source/core/tool/cellform.cxx |6 +++---
 sc/source/ui/view/cellsh1.cxx|7 ---
 svl/source/numbers/zforlist.cxx  |5 +++--
 11 files changed, 28 insertions(+), 25 deletions(-)

New commits:
commit a88419f54b8aa9c23cd80e04bc47f1b5ef3931ca
Author: Daniel Kamil Kozar 
AuthorDate: Tue May 3 02:45:13 2022 +0200
Commit: Eike Rathke 
CommitDate: Fri May 6 14:16:12 2022 +0200

tdf#148383: Obtain start/end strings always in system locale

ScFillSeriesDlg always expects the strings describing the start and end 
values
to be in the system locale. This change ensures that and fixes the bug where
using non-locale-default data in the Fill Series dialog leads to an error.

Change-Id: I25eafa2174294dc35a63473a54c529c2d7bd87ea
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132532
Tested-by: Jenkins
Reviewed-by: Eike Rathke 

diff --git a/include/svl/numformat.hxx b/include/svl/numformat.hxx
index 2187810229aa..dc1c704d364d 100644
--- a/include/svl/numformat.hxx
+++ b/include/svl/numformat.hxx
@@ -203,7 +203,7 @@ public:
 in the filtering condition now), instead of the EditFormat string
 (e.g a not rounded value, which is visible during editing).*/
 void GetInputLineString(const double& fOutNumber, sal_uInt32 nFIndex, 
OUString& rOutString,
-bool bFiltering = false);
+bool bFiltering = false, bool bForceSystemLocale = 
false);
 
 /** Format a number according to a format code string to be scanned.
 @return
diff --git a/sc/inc/cellform.hxx b/sc/inc/cellform.hxx
index cd9b28f7692c..7fb072ee8578 100644
--- a/sc/inc/cellform.hxx
+++ b/sc/inc/cellform.hxx
@@ -46,13 +46,14 @@ public:
 // Note that if pShared is set and a value is returned that way, the 
returned OUString is empty.
 static OUString GetInputString(
 const ScRefCellValue& rCell, sal_uInt32 nFormat, SvNumberFormatter& 
rFormatter,
-const ScDocument& rDoc, const svl::SharedString** pShared = nullptr, 
bool bFiltering = false );
+const ScDocument& rDoc, const svl::SharedString** pShared = nullptr, 
bool bFiltering = false,
+bool bForceSystemLocale = false );
 
 static OUString GetInputString(
 const ScRefCellValue& rCell, sal_uInt32 nFormat, SvNumberFormatter& 
rFormatter,
-const ScDocument& rDoc, bool bFiltering)
+const ScDocument& rDoc, bool bFiltering, bool bForceSystemLocale = 
false )
 {
-return GetInputString( rCell, nFormat, rFormatter, rDoc, nullptr, 
bFiltering );
+return GetInputString( rCell, nFormat, rFormatter, rDoc, nullptr, 
bFiltering, bForceSystemLocale );
 }
 
 static OUString GetOutputString(
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index ed9ce2e0c77c..3f0785429ca9 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -442,11 +442,11 @@ public:
 { return GetString( GetCellValue( rBlockPos, nRow ), nRow, pContext ); 
}
 double* GetValueCell( SCROW nRow );
 // Note that if pShared is set and a value is returned that way, the 
returned OUString is empty.
-OUStringGetInputString( SCROW nRow, const svl::SharedString** pShared 
= nullptr ) const
-{ return GetInputString( GetCellValue( nRow ), nRow, pShared ); }
+OUStringGetInputString( SCROW nRow, const svl::SharedString** pShared 
= nullptr, bool bForceSystemLocale = false ) const
+{ return GetInputString( GetCellValue( nRow ), nRow, pShared, 
bForceSystemLocale ); }
 OUStringGetInputString( sc::ColumnBlockConstPosition& rBlockPos, SCROW 
nRow,
-const svl::SharedString** pShared = nullptr ) const
-{ return GetInputString( GetCellValue( rBlockPos, nRow ), nRow, 
pShared ); }
+const svl::SharedString** pShared = nullptr, bool 
bForceSystemLocale = false ) const
+{ return GetInputString( GetCellValue( rBlockPos, nRow ), nRow, 
pShared, bForceSystemLocale ); }
 double  GetValue( SCROW nRow ) const;
 const EditTextObject* GetEditText( SCROW nRow ) const;
 void RemoveEditTextCharAttribs( SCROW nRow, const ScPatternAttr& rAttr );
@@ -822,7 +822,7 @@ private:
 SCROW FindNextVisibleRow(SCROW nRow, bool bForward) const;
 
 OUString GetString( const ScRefCellValue& cell, SCROW nRow, const 
ScInterpreterContext* pContext = nullptr ) const;
-OUString GetInputString( const ScRefCellValue& cell, SCROW nRow, const 
svl::SharedString** pShared = nullptr ) const;
+OUString GetInputString( const ScRefCellValue& cell, SCROW nRow, const 

[Libreoffice-commits] core.git: include/svl sc/inc sc/source svl/source

2022-03-05 Thread Luboš Luňák (via logerrit)
 include/svl/broadcast.hxx  |2 -
 sc/inc/column.hxx  |4 ++-
 sc/inc/document.hxx|6 +
 sc/inc/mtvfunctions.hxx|   40 +
 sc/inc/scopetools.hxx  |   11 ++
 sc/inc/table.hxx   |1 
 sc/source/core/data/column.cxx |3 +-
 sc/source/core/data/column2.cxx|   30 +--
 sc/source/core/data/documen2.cxx   |1 
 sc/source/core/data/document10.cxx |   13 
 sc/source/core/data/table1.cxx |6 +
 sc/source/core/data/table3.cxx |2 +
 sc/source/core/tool/scopetools.cxx |   12 +++
 svl/source/notify/broadcast.cxx|7 --
 14 files changed, 127 insertions(+), 11 deletions(-)

New commits:
commit 648a4b30b33569052847b797c38e52ba2fd2d500
Author: Luboš Luňák 
AuthorDate: Sat Mar 5 22:11:30 2022 +0100
Commit: Luboš Luňák 
CommitDate: Sun Mar 6 08:19:51 2022 +0100

do not destroy broadcasters and then recreate again (tdf#134268)

Sorting ends tells all listeners on all the sorted cells to end
listening to stop updates, then sorts the cells and starts
listening again. This will cause all broadcasters for the sorted
cells to temporarily stop having any listeners, so they'll be
deleted and removed from the mdds vector (which may additionally
cause moving large parts of the mdds vector repeatedly). And
since all listeners will want to listen again after the sort,
this will all need to be reconstructed. To avoid this,
temporarily block this removal and then later just checks
and remove any possibly left-over broadcasters that ended up
with no listeners.

Change-Id: Ie2d41d9acd7b657cf31a445870ce7f18d28d5ebb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131069
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/include/svl/broadcast.hxx b/include/svl/broadcast.hxx
index c1996ccfeda7..eaf4de8ba448 100644
--- a/include/svl/broadcast.hxx
+++ b/include/svl/broadcast.hxx
@@ -59,7 +59,7 @@ public:
 ListenersType& GetAllListeners();
 const ListenersType& GetAllListeners() const;
 
-bool HasListeners() const;
+bool HasListeners() const { return (maListeners.size() - mnEmptySlots) > 
0; }
 
 /**
  * Listeners and broadcasters are M:N relationship.  If you want to
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 1ec4aac4204b..1b1ae1e6ab93 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -178,7 +178,8 @@ class ScColumn : protected ScColumnData
 SCCOL   nCol;
 SCTAB   nTab;
 
-bool mbFiltering; // it is true if there is a filtering in the column
+bool mbFiltering : 1; // it is true if there is a filtering in the column
+bool mbEmptyBroadcastersPending : 1; // a broadcaster not removed during 
EnableDelayDeletingBroadcasters()
 
 friend class ScDocument;// for FillInfo
 friend class ScTable;
@@ -633,6 +634,7 @@ public:
 
 void DeleteBroadcasters( sc::ColumnBlockPosition& rBlockPos, SCROW nRow1, 
SCROW nRow2 );
 void PrepareBroadcastersForDestruction();
+void DeleteEmptyBroadcasters();
 
 void Broadcast( SCROW nRow );
 void BroadcastCells( const std::vector& rRows, SfxHintId nHint );
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index f78afc46a3da..ddd59d16f3d3 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -525,6 +525,8 @@ private:
 // avoiding repeated calling for the same cells in the given range. The 
function will be called once
 // later for all the cells in the range.
 std::unordered_map< ScColumn*, std::pair> 
pDelayedStartListeningFormulaCells;
+// Cells will not delete their broadcasters if delayed, avoiding possible 
extensive mdds vector changes.
+boolbDelayedDeletingBroadcasters;
 
 boolbLinkFormulaNeedingCheck; // valid only after loading, 
for ocDde and ocWebservice
 
@@ -1391,6 +1393,10 @@ public:
 /// If true is returned, ScColumn::StartListeningFormulaCells() for the 
given cells will be performed
 /// later. If false is returned, it needs to be done explicitly.
 boolCanDelayStartListeningFormulaCells( ScColumn* column, 
SCROW row1, SCROW row2 );
+/// If set, cells will not delete their empty broadcasters, avoiding 
possible extensive mdds
+/// vector changes. Disabling delay will collect and delete all empty 
broadcasters.
+voidEnableDelayDeletingBroadcasters(bool set);
+boolIsDelayedDeletingBroadcasters() const { return 
bDelayedDeletingBroadcasters; }
 
 FormulaErrorGetErrCode( const ScAddress& ) const;
 
diff --git a/sc/inc/mtvfunctions.hxx b/sc/inc/mtvfunctions.hxx
index 8f69c05c39fd..9fe394faff57 100644
--- a/sc/inc/mtvfunctions.hxx
+++ b/sc/inc/mtvfunctions.hxx
@@ -23,6 +23,17 @@ struct FuncElseNoOp
 }
 };
 
+template
+struct FuncNotElem
+{
+ 

[Libreoffice-commits] core.git: include/svl sc/inc sc/source svl/source

2022-02-21 Thread Luboš Luňák (via logerrit)
 include/svl/poolitem.hxx|   17 -
 include/svl/setitem.hxx |1 -
 sc/inc/patattr.hxx  |6 +++---
 sc/source/core/data/patattr.cxx |   25 ++---
 svl/source/items/itempool.cxx   |   30 ++
 svl/source/items/sitem.cxx  |5 -
 6 files changed, 43 insertions(+), 41 deletions(-)

New commits:
commit b26c34267cdf9d0b7ba4e2fda7ae706d5cd76299
Author: Luboš Luňák 
AuthorDate: Mon Feb 21 00:57:21 2022 +0100
Commit: Luboš Luňák 
CommitDate: Mon Feb 21 12:29:49 2022 +0100

replace SfxPoolItem::LookupHashCode() with Lookup() (tdf#135215)

The LookupHashCode() way still loops over an array while calling
virtual functions for a type that is actually known. Overriding
instead a whole new Lookup() function that does the loop
avoids the virtual calls, allowing compiler optimizations such
as inlining, or class-specific optimizations like the hash code.
So this still improves performance with ScPatternAttr a bit,
for tdf#135215 it saves about 40% of load time, but this is
scraping the bottom of the barrel, as this is still a linear search
(the IsSortable() approach, if it worked, would be still 3x faster).

Change-Id: I8fe5f70cabb77e2f6619d169beee8a3b4da46213
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130228
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/include/svl/poolitem.hxx b/include/svl/poolitem.hxx
index 1549cd0a6298..10a7901b4e70 100644
--- a/include/svl/poolitem.hxx
+++ b/include/svl/poolitem.hxx
@@ -23,6 +23,7 @@
 #include 
 
 #include 
+#include 
 
 #include 
 #include 
@@ -187,13 +188,19 @@ public:
 // of a single kind of pool item.
 virtual bool operator<( const SfxPoolItem& ) const { 
assert(false); return false; }
 virtual bool IsSortable() const { return false; }
+
 // Some item types cannot be IsSortable() (such as because they are 
modified while stored
 // in a pool, which would change the ordering position, see e.g. 
585e0ac43b9bd8a2f714903034).
-// To improve performance in such cases it is possible to return a 
(fast/cached) non-zero hash code,
-// which will be used to speed up linear lookup and only matching items 
will be fully compared.
-// Note: Since 0 value is invalid, try to make sure it's not returned for 
valid items
-// (which may easily happen e.g. if the item is empty and the hash is 
seeded with 0).
-virtual size_t   LookupHashCode() const { return 0; }
+// To improve performance in such cases it is possible to reimplement 
Lookup() to do a linear
+// lookup optimized for the specific class (avoiding virtual functions may 
allow the compiler
+// to generate better code and class-specific optimizations such as 
hashing or caching may
+// be used.)
+// If reimplemented, the Lookup() function should search [begin,end) for 
an item matching
+// this object and return an iterator pointing to the item or the end 
iterator.
+virtual bool HasLookup() const { return false; }
+typedef std::vector::const_iterator lookup_iterator;
+virtual lookup_iterator  Lookup(lookup_iterator /*begin*/, lookup_iterator 
end ) const
+ { assert( false ); return end; }
 
 /**  @return true if it has a valid string representation */
 virtual bool GetPresentation( SfxItemPresentation 
ePresentation,
diff --git a/include/svl/setitem.hxx b/include/svl/setitem.hxx
index 8a7c39f08ea0..69ebea4b1d23 100644
--- a/include/svl/setitem.hxx
+++ b/include/svl/setitem.hxx
@@ -34,7 +34,6 @@ public:
 SfxSetItem(sal_uInt16 nWhich, SfxItemSet&& pSet);
 SfxSetItem(sal_uInt16 nWhich, const SfxItemSet& rSet);
 SfxSetItem(const SfxSetItem&, SfxItemPool* pPool = nullptr);
-virtual ~SfxSetItem() override;
 
 virtual bool operator==(const SfxPoolItem&) const override;
 
diff --git a/sc/inc/patattr.hxx b/sc/inc/patattr.hxx
index 2618cf00..4570924d5d17 100644
--- a/sc/inc/patattr.hxx
+++ b/sc/inc/patattr.hxx
@@ -60,12 +60,12 @@ public:
 ScPatternAttr(SfxItemPool* pItemPool);
 ScPatternAttr(const ScPatternAttr& rPatternAttr);
 
-virtual ~ScPatternAttr() override;
-
 virtual ScPatternAttr*  Clone( SfxItemPool *pPool = nullptr ) const 
override;
 
 virtual booloperator==(const SfxPoolItem& rCmp) const override;
-virtual size_t  LookupHashCode() const override;
+// Class cannot be IsSortable() because it's mutable, implement at least 
Lookup().
+virtual boolHasLookup() const override { return true; }
+virtual lookup_iterator Lookup(lookup_iterator begin, lookup_iterator end 
) const override;
 
 const SfxPoolItem&  GetItem( sal_uInt16 nWhichP ) const
 { return 

[Libreoffice-commits] core.git: include/svl sc/inc sc/source svl/source

2022-02-08 Thread Luboš Luňák (via logerrit)
 include/svl/poolitem.hxx|7 +++
 sc/inc/patattr.hxx  |1 +
 sc/source/core/data/patattr.cxx |   10 +-
 svl/source/items/itempool.cxx   |   24 
 4 files changed, 37 insertions(+), 5 deletions(-)

New commits:
commit 98d51bf8ce13bdac2d71f50f58d6d0ddb9041a4f
Author: Luboš Luňák 
AuthorDate: Tue Feb 8 11:36:42 2022 +0100
Commit: Luboš Luňák 
CommitDate: Tue Feb 8 20:57:41 2022 +0100

speed up SfxItemPool searches with items that can't use IsSortable()

As pointed out by 585e0ac43b9bd8a2f714903034e435c84ae3fc96, some
item types cannot be used as IsSortable(), because they are modified
after having been inserted in the pool, which breaks the sorted
order. But it's possible to at least somewhat improve performance
of these items by explicitly providing a hash code and using
that first for comparisons when looking up items, which may be
cheaper than calling operator==.
With ScPatternAttr such comparisons seem to take only 60% of the
original time, reducing loading time of some documents by 25%.

Change-Id: I41f4dda472fb6db066742976672f2c08b9aeef63
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129667
Reviewed-by: Noel Grandin 
Reviewed-by: Luboš Luňák 
Tested-by: Jenkins

diff --git a/include/svl/poolitem.hxx b/include/svl/poolitem.hxx
index ba22aed9a9cc..1549cd0a6298 100644
--- a/include/svl/poolitem.hxx
+++ b/include/svl/poolitem.hxx
@@ -187,6 +187,13 @@ public:
 // of a single kind of pool item.
 virtual bool operator<( const SfxPoolItem& ) const { 
assert(false); return false; }
 virtual bool IsSortable() const { return false; }
+// Some item types cannot be IsSortable() (such as because they are 
modified while stored
+// in a pool, which would change the ordering position, see e.g. 
585e0ac43b9bd8a2f714903034).
+// To improve performance in such cases it is possible to return a 
(fast/cached) non-zero hash code,
+// which will be used to speed up linear lookup and only matching items 
will be fully compared.
+// Note: Since 0 value is invalid, try to make sure it's not returned for 
valid items
+// (which may easily happen e.g. if the item is empty and the hash is 
seeded with 0).
+virtual size_t   LookupHashCode() const { return 0; }
 
 /**  @return true if it has a valid string representation */
 virtual bool GetPresentation( SfxItemPresentation 
ePresentation,
diff --git a/sc/inc/patattr.hxx b/sc/inc/patattr.hxx
index e6ac9603dd17..f60144c2feaf 100644
--- a/sc/inc/patattr.hxx
+++ b/sc/inc/patattr.hxx
@@ -66,6 +66,7 @@ public:
 virtual ScPatternAttr*  Clone( SfxItemPool *pPool = nullptr ) const 
override;
 
 virtual booloperator==(const SfxPoolItem& rCmp) const override;
+virtual size_t  LookupHashCode() const override;
 
 const SfxPoolItem&  GetItem( sal_uInt16 nWhichP ) const
 { return GetItemSet().Get(nWhichP); }
diff --git a/sc/source/core/data/patattr.cxx b/sc/source/core/data/patattr.cxx
index f474cb052232..c92c409804e5 100644
--- a/sc/source/core/data/patattr.cxx
+++ b/sc/source/core/data/patattr.cxx
@@ -154,6 +154,13 @@ bool ScPatternAttr::operator==( const SfxPoolItem& rCmp ) 
const
 StrCmp( GetStyleName(), rOther.GetStyleName() );
 }
 
+size_t ScPatternAttr::LookupHashCode() const
+{
+if (!mxHashCode)
+CalcHashCode();
+return *mxHashCode;
+}
+
 SvxCellOrientation ScPatternAttr::GetCellOrientation( const SfxItemSet& 
rItemSet, const SfxItemSet* pCondSet )
 {
 SvxCellOrientation eOrient = SvxCellOrientation::Standard;
@@ -1367,7 +1374,8 @@ sal_uInt64 ScPatternAttr::GetKey() const
 void ScPatternAttr::CalcHashCode() const
 {
 auto const & rSet = GetItemSet();
-mxHashCode = boost::hash_range(rSet.GetItems_Impl(), rSet.GetItems_Impl() 
+ rSet.Count());
+mxHashCode = 1; // Set up seed so that an empty pattern does not have an 
(invalid) hash of 0.
+boost::hash_range(*mxHashCode, rSet.GetItems_Impl(), rSet.GetItems_Impl() 
+ rSet.Count());
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svl/source/items/itempool.cxx b/svl/source/items/itempool.cxx
index 8d4aa074e4f5..acd5c77de452 100644
--- a/svl/source/items/itempool.cxx
+++ b/svl/source/items/itempool.cxx
@@ -627,12 +627,28 @@ const SfxPoolItem& SfxItemPool::PutImpl( const 
SfxPoolItem& rItem, sal_uInt16 nW
 }
 else
 {
-for (auto itr = rItemArr.begin(); itr != rItemArr.end(); ++itr)
+// If the item provides a valid hash, use that to speed up 
comparisons.
+size_t lookupHashCode = rItem.LookupHashCode();
+if (lookupHashCode != 0)
 {
-if (**itr == rItem)
+for (auto itr = rItemArr.begin(); itr != rItemArr.end(); ++itr)
 {
-

[Libreoffice-commits] core.git: include/svl sc/inc sc/source svl/source sw/inc sw/source

2021-02-26 Thread Noel (via logerrit)
 include/svl/style.hxx |2 +-
 sc/inc/stlpool.hxx|2 +-
 sc/source/core/data/stlpool.cxx   |2 +-
 svl/source/items/style.cxx|2 +-
 sw/inc/docstyle.hxx   |2 +-
 sw/source/uibase/app/docstyle.cxx |2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)

New commits:
commit f77250f3159ec58f8d7d2770496fac64536b4f6f
Author: Noel 
AuthorDate: Thu Feb 25 15:14:18 2021 +0200
Commit: Noel Grandin 
CommitDate: Fri Feb 26 13:10:49 2021 +0100

loplugin:refcounting in svl

Change-Id: I0009464121faf6dd36793b031d892f492b56187c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111544
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/include/svl/style.hxx b/include/svl/style.hxx
index bd1b0adb0790..735e3607242d 100644
--- a/include/svl/style.hxx
+++ b/include/svl/style.hxx
@@ -238,7 +238,7 @@ protected:
 
 voidChangeParent(std::u16string_view rOld, const 
OUString& rNew, SfxStyleFamily eFamily, bool bVirtual = true);
 virtual rtl::Reference Create( const OUString&, 
SfxStyleFamily, SfxStyleSearchBits );
-virtual SfxStyleSheetBase*  Create( const SfxStyleSheetBase& );
+virtual rtl::Reference  Create( const 
SfxStyleSheetBase& );
 
 virtual ~SfxStyleSheetBasePool() override;
 
diff --git a/sc/inc/stlpool.hxx b/sc/inc/stlpool.hxx
index b4a5c312d6ea..e6d816096d9d 100644
--- a/sc/inc/stlpool.hxx
+++ b/sc/inc/stlpool.hxx
@@ -66,7 +66,7 @@ private:
 virtual rtl::Reference Create( const OUString&  rName,
SfxStyleFamily   eFamily,
SfxStyleSearchBits nMask) override;
-virtual SfxStyleSheetBase* Create( const SfxStyleSheetBase& rStyle ) 
override;
+virtual rtl::Reference Create( const SfxStyleSheetBase& 
rStyle ) override;
 
 SfxStyleSheetBase*  pActualStyleSheet;
 ScDocument* pDoc;
diff --git a/sc/source/core/data/stlpool.cxx b/sc/source/core/data/stlpool.cxx
index 3654799790da..b4074c1773b5 100644
--- a/sc/source/core/data/stlpool.cxx
+++ b/sc/source/core/data/stlpool.cxx
@@ -107,7 +107,7 @@ rtl::Reference ScStyleSheetPool::Create( 
const OUString&   rN
 return pSheet;
 }
 
-SfxStyleSheetBase* ScStyleSheetPool::Create( const SfxStyleSheetBase& rStyle )
+rtl::Reference ScStyleSheetPool::Create( const 
SfxStyleSheetBase& rStyle )
 {
 OSL_ENSURE( rStyle.isScStyleSheet(), "Invalid StyleSheet-class! :-/" );
 return new ScStyleSheet( static_cast(rStyle) );
diff --git a/svl/source/items/style.cxx b/svl/source/items/style.cxx
index 5b430259de2a..a053044b7de9 100644
--- a/svl/source/items/style.cxx
+++ b/svl/source/items/style.cxx
@@ -615,7 +615,7 @@ rtl::Reference 
SfxStyleSheetBasePool::Create
 return new SfxStyleSheetBase( rName, this, eFam, mask );
 }
 
-SfxStyleSheetBase* SfxStyleSheetBasePool::Create( const SfxStyleSheetBase& r )
+rtl::Reference SfxStyleSheetBasePool::Create( const 
SfxStyleSheetBase& r )
 {
 return new SfxStyleSheetBase( r );
 }
diff --git a/sw/inc/docstyle.hxx b/sw/inc/docstyle.hxx
index 90ad2f61ff7c..3ac7b308315d 100644
--- a/sw/inc/docstyle.hxx
+++ b/sw/inc/docstyle.hxx
@@ -198,7 +198,7 @@ class SwDocStyleSheetPool : public SfxStyleSheetBasePool
 boolbOrganizer : 1; ///< Organizer
 
 virtual rtl::Reference Create( const OUString&, 
SfxStyleFamily, SfxStyleSearchBits nMask) override;
-virtual SfxStyleSheetBase* Create( const SfxStyleSheetBase& ) override;
+virtual rtl::Reference Create( const SfxStyleSheetBase& 
) override;
 
 using SfxStyleSheetBasePool::Find;
 
diff --git a/sw/source/uibase/app/docstyle.cxx 
b/sw/source/uibase/app/docstyle.cxx
index 102afc1a3253..e173eddfbc3d 100644
--- a/sw/source/uibase/app/docstyle.cxx
+++ b/sw/source/uibase/app/docstyle.cxx
@@ -2428,7 +2428,7 @@ SfxStyleSheetBase&   SwDocStyleSheetPool::Make( const 
OUString&   rName,
 return *mxStyleSheet;
 }
 
-SfxStyleSheetBase*   SwDocStyleSheetPool::Create( const SfxStyleSheetBase& 
/*rOrg*/)
+rtl::Reference SwDocStyleSheetPool::Create( const 
SfxStyleSheetBase& /*rOrg*/)
 {
 OSL_ENSURE(false , "Create in SW-Stylesheet-Pool not possible" );
 return nullptr;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: include/svl sc/inc sc/source svl/source

2019-04-20 Thread Noel Grandin (via logerrit)
 include/svl/itempool.hxx  |7 +++
 sc/inc/attarray.hxx   |   16 +++-
 sc/inc/column.hxx |7 ++-
 sc/inc/docpool.hxx|4 +-
 sc/inc/document.hxx   |2 +
 sc/inc/table.hxx  |8 +---
 sc/source/core/data/attarray.cxx  |   71 ++
 sc/source/core/data/column.cxx|   15 ++--
 sc/source/core/data/column4.cxx   |6 +--
 sc/source/core/data/docpool.cxx   |6 +--
 sc/source/core/data/document.cxx  |8 
 sc/source/core/data/table2.cxx|   19 ++
 sc/source/core/data/table3.cxx|6 +--
 sc/source/filter/rtf/eeimpars.cxx |   44 +++
 sc/source/ui/undo/undocell.cxx|6 +--
 svl/source/items/itempool.cxx |   20 +-
 16 files changed, 157 insertions(+), 88 deletions(-)

New commits:
commit c757117afb398277a46e79ba22066c5bbf2c9f72
Author: Noel Grandin 
AuthorDate: Sat Apr 20 13:03:33 2019 +0200
Commit: Noel Grandin 
CommitDate: Sun Apr 21 07:58:14 2019 +0200

tdf#81765 slow loading of .ods with >1000 of conditional formats, part 2

This takes the loading time from 15s to 14s.

Reduce unnecessary allocation/copying by passing down ownership of the
newly created ScPatternAttr to the item pool

Change-Id: Iec38bbff572d10ff8d86f5e65fbe9a96b6a5a706
Reviewed-on: https://gerrit.libreoffice.org/71010
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/include/svl/itempool.hxx b/include/svl/itempool.hxx
index f987cf15ae62..391e1b942544 100644
--- a/include/svl/itempool.hxx
+++ b/include/svl/itempool.hxx
@@ -146,7 +146,10 @@ public:
 virtual SfxItemPool*Clone() const;
 const OUString& GetName() const;
 
-virtual const SfxPoolItem&  Put( const SfxPoolItem&, sal_uInt16 nWhich 
= 0 );
+const SfxPoolItem&  Put( std::unique_ptr xItem, 
sal_uInt16 nWhich = 0 )
+{ return PutImpl( *xItem.release(), nWhich, /*bPassingOwnership*/true); }
+const SfxPoolItem&  Put( const SfxPoolItem& rItem, sal_uInt16 
nWhich = 0 )
+{ return PutImpl( rItem, nWhich, /*bPassingOwnership*/false); }
 voidRemove( const SfxPoolItem& );
 
 const SfxPoolItem&  GetDefaultItem( sal_uInt16 nWhich ) const;
@@ -195,6 +198,8 @@ public:
 
 voiddumpAsXml(xmlTextWriterPtr pWriter) const;
 
+protected:
+virtual const SfxPoolItem&  PutImpl( const SfxPoolItem&, sal_uInt16 
nWhich = 0, bool bPassingOwnership = false );
 private:
 const SfxItemPool&  operator=(const SfxItemPool &) = delete;
 
diff --git a/sc/inc/attarray.hxx b/sc/inc/attarray.hxx
index d2ca2d7c842f..b43befd45e84 100644
--- a/sc/inc/attarray.hxx
+++ b/sc/inc/attarray.hxx
@@ -137,9 +137,16 @@ public:
 voidApplyBlockFrame(const SvxBoxItem& rLineOuter, const 
SvxBoxInfoItem* pLineInner,
 SCROW nStartRow, SCROW nEndRow, bool bLeft, SCCOL 
nDistRight);
 
-voidSetPattern( SCROW nRow, const ScPatternAttr* pPattern, bool 
bPutToPool = false );
+voidSetPattern( SCROW nRow, const ScPatternAttr* pPattern, bool 
bPutToPool = false )
+{ SetPatternAreaImpl(nRow, nRow, pPattern, bPutToPool, nullptr, 
/*bPassingOwnership*/false); }
+const ScPatternAttr* SetPattern( SCROW nRow, 
std::unique_ptr pPattern, bool bPutToPool = false )
+{ return SetPatternAreaImpl(nRow, nRow, pPattern.release(), bPutToPool, 
nullptr, /*bPassingOwnership*/true); }
+voidSetPatternArea( SCROW nStartRow, SCROW nEndRow, 
std::unique_ptr pPattern,
+bool bPutToPool = false, ScEditDataArray* 
pDataArray = nullptr)
+{ SetPatternAreaImpl(nStartRow, nEndRow, pPattern.release(), bPutToPool, 
pDataArray, /*bPassingOwnership*/true); }
 voidSetPatternArea( SCROW nStartRow, SCROW nEndRow, const 
ScPatternAttr* pPattern,
-bool bPutToPool = false, ScEditDataArray* 
pDataArray = nullptr );
+bool bPutToPool = false, ScEditDataArray* 
pDataArray = nullptr)
+{ SetPatternAreaImpl(nStartRow, nEndRow, pPattern, bPutToPool, pDataArray, 
/*bPassingOwnership*/false); }
 voidApplyStyleArea( SCROW nStartRow, SCROW nEndRow, const 
ScStyleSheet& rStyle );
 voidApplyCacheArea( SCROW nStartRow, SCROW nEndRow, SfxItemPoolCache* 
pCache,
 ScEditDataArray* pDataArray = nullptr, bool* const 
pIsChanged = nullptr );
@@ -210,6 +217,11 @@ public:
 boolReserve( SCSIZE nReserve );
 SCSIZE  Count() const { return mvData.size(); }
 SCSIZE  Count( SCROW nRow1, SCROW nRow2 ) const;
+
+private:
+const ScPatternAttr* SetPatternAreaImpl( SCROW nStartRow, SCROW nEndRow, 
const ScPatternAttr* pPattern,
+bool bPutToPool = false, ScEditDataArray* 
pDataArray = nullptr,
+bool 

[Libreoffice-commits] core.git: include/svl sc/inc sc/source svl/source

2019-04-20 Thread Noel Grandin (via logerrit)
 include/svl/poolitem.hxx|5 +++
 sc/inc/attrib.hxx   |2 +
 sc/inc/patattr.hxx  |2 +
 sc/source/core/data/attrib.cxx  |   16 +++
 sc/source/core/data/patattr.cxx |   54 +++-
 svl/source/inc/poolio.hxx   |   30 --
 svl/source/items/itempool.cxx   |   23 +
 svl/source/items/poolio.cxx |1 
 8 files changed, 124 insertions(+), 9 deletions(-)

New commits:
commit 003d11f410b7e515981b3efbd65d936d94d87121
Author: Noel Grandin 
AuthorDate: Sat Apr 20 08:32:33 2019 +0200
Commit: Noel Grandin 
CommitDate: Sat Apr 20 18:18:20 2019 +0200

tdf#81765 slow loading of .ods with >1000 of conditional formats

This takes the loaing time from 1m38 to 15s.

Speed up finding existing pool items in the pool by storing a
sorted_vector, sorted by a compare operator on the item.

memcmp is faster than operator< on std::vector because operator< seems
to be trying to use some kind of lexicographical compare

Change-Id: Id72527106d604adb8cd2d158bb42f89e2b16a85d
Reviewed-on: https://gerrit.libreoffice.org/71009
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/include/svl/poolitem.hxx b/include/svl/poolitem.hxx
index c1c017c13f44..c3800cc02c18 100644
--- a/include/svl/poolitem.hxx
+++ b/include/svl/poolitem.hxx
@@ -152,6 +152,11 @@ public:
 bool operator!=( const SfxPoolItem& rItem ) const
  { return !(*this == rItem); }
 
+// Sorting is only used for faster searching in a pool which contains 
large quantities
+// of a single kind of pool item.
+virtual bool operator<( const SfxPoolItem& ) const { 
assert(false); return false; }
+virtual bool IsSortable() const { return false; }
+
 /**  @return true if it has a valid string representation */
 virtual bool GetPresentation( SfxItemPresentation 
ePresentation,
 MapUnit eCoreMetric,
diff --git a/sc/inc/attrib.hxx b/sc/inc/attrib.hxx
index 9e4a556080e4..e03d1a223d66 100644
--- a/sc/inc/attrib.hxx
+++ b/sc/inc/attrib.hxx
@@ -269,6 +269,8 @@ public:
 virtual ~ScCondFormatItem() override;
 
 virtual bool operator==(const SfxPoolItem& rCmp ) const override;
+virtual booloperator<(const SfxPoolItem& rCmp) const override;
+virtual boolIsSortable() const override { return true; }
 virtual ScCondFormatItem*  Clone( SfxItemPool* = nullptr ) const override;
 
 const std::vector& GetCondFormatData() const { return maIndex;}
diff --git a/sc/inc/patattr.hxx b/sc/inc/patattr.hxx
index 8004a57c3a26..52fd8536d861 100644
--- a/sc/inc/patattr.hxx
+++ b/sc/inc/patattr.hxx
@@ -65,6 +65,8 @@ public:
 virtual SfxPoolItem*Clone( SfxItemPool *pPool = nullptr ) const 
override;
 
 virtual booloperator==(const SfxPoolItem& rCmp) const override;
+virtual booloperator<(const SfxPoolItem& rCmp) const override;
+virtual boolIsSortable() const override { return true; }
 
 const SfxPoolItem&  GetItem( sal_uInt16 nWhichP ) const
 { return GetItemSet().Get(nWhichP); }
diff --git a/sc/source/core/data/attrib.cxx b/sc/source/core/data/attrib.cxx
index 43cb67ecd91d..37c9c51b612d 100644
--- a/sc/source/core/data/attrib.cxx
+++ b/sc/source/core/data/attrib.cxx
@@ -682,7 +682,21 @@ ScCondFormatItem::~ScCondFormatItem()
 
 bool ScCondFormatItem::operator==( const SfxPoolItem& rCmp ) const
 {
-return maIndex == static_cast(rCmp).maIndex;
+auto const & other = static_cast(rCmp);
+// memcmp is faster than operator< on std::vector
+return maIndex.size() == other.maIndex.size()
+&& memcmp(maIndex.data(), other.maIndex.data(), maIndex.size() * 
sizeof(sal_uInt32)) == 0;
+}
+
+bool ScCondFormatItem::operator<( const SfxPoolItem& rCmp ) const
+{
+auto const & other = static_cast(rCmp);
+if ( maIndex.size() < other.maIndex.size() )
+return true;
+if ( maIndex.size() > other.maIndex.size() )
+return false;
+// memcmp is faster than operator< on std::vector
+return memcmp(maIndex.data(), other.maIndex.data(), maIndex.size() * 
sizeof(sal_uInt32)) < 0;
 }
 
 ScCondFormatItem* ScCondFormatItem::Clone(SfxItemPool*) const
diff --git a/sc/source/core/data/patattr.cxx b/sc/source/core/data/patattr.cxx
index 4c3c937b4088..bff76e330233 100644
--- a/sc/source/core/data/patattr.cxx
+++ b/sc/source/core/data/patattr.cxx
@@ -111,7 +111,30 @@ SfxPoolItem* ScPatternAttr::Clone( SfxItemPool *pPool ) 
const
 
 static bool StrCmp( const OUString* pStr1, const OUString* pStr2 )
 {
-return ( pStr1 ? ( pStr2 && ( *pStr1 == *pStr2 ) ) : ( pStr2 == nullptr ) 
);
+if (pStr1 == pStr2)
+return true;
+if (pStr1 && !pStr2)
+return false;
+if (!pStr1 && pStr2)
+return 

[Libreoffice-commits] core.git: include/svl sc/inc sc/source svl/source

2013-12-20 Thread Jan Holesovsky
 include/svl/broadcast.hxx   |   13 +
 sc/inc/column.hxx   |1 +
 sc/source/core/data/column2.cxx |   15 +++
 sc/source/core/data/table1.cxx  |3 +++
 svl/source/notify/broadcast.cxx |9 ++---
 5 files changed, 38 insertions(+), 3 deletions(-)

New commits:
commit efb30219a1113ee08bf26160a08b4f721a514fdf
Author: Jan Holesovsky ke...@collabora.com
Date:   Sat Dec 21 01:41:18 2013 +0100

Speedup destruction of sheets with too many listeners  broadcasters.

Listeners and broadcasters are M:N relationship.  If you want to
destruct them, you easily end up in O(M*N) situation; where for every
listener, you iterate all broadcasters, to remove that one listener.

To avoid that, announce to the broadcasters that they are going to die, and 
the
listeners do not have to bother with removing themselves from the 
broadcaster.
The broadcaster will not broadcast anything after the 
PrepareForDesctruction()
call anyway.

Change-Id: I68d78b23e73bcbb944de9139448b2c20dfa14f62

diff --git a/include/svl/broadcast.hxx b/include/svl/broadcast.hxx
index 6a6bc03..d122e02 100644
--- a/include/svl/broadcast.hxx
+++ b/include/svl/broadcast.hxx
@@ -60,8 +60,21 @@ public:
 
 bool HasListeners() const;
 
+/**
+ * Listeners and broadcasters are M:N relationship.  If you want to
+ * destruct them, you easily end up in O(M*N) situation; where for every
+ * listener, you iterate all broadcasters, to remove that one listener.
+ *
+ * To avoid that, use this call to announce to the broadcaster it is going
+ * to die, and the listeners do not have to bother with removing
+ * themselves from the broadcaster - the broadcaster will not broadcast
+ * anything after the PrepareForDesctruction() call anyway.
+ */
+void PrepareForDestruction() { mbAboutToDie = true; }
+
 private:
 ListenersType maListeners;
+bool mbAboutToDie:1;
 bool mbDisposing:1;
 bool mbNormalized:1;
 };
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 55b3847..b7f48db 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -491,6 +491,7 @@ public:
 SvtBroadcaster* GetBroadcaster( SCROW nRow );
 const SvtBroadcaster* GetBroadcaster( SCROW nRow ) const;
 void DeleteBroadcasters( sc::ColumnBlockPosition rBlockPos, SCROW nRow1, 
SCROW nRow2 );
+void PrepareBroadcastersForDestruction();
 bool HasBroadcaster() const;
 
 void Broadcast( SCROW nRow );
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index 307d42b..2092406b 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -1962,6 +1962,21 @@ void ScColumn::DeleteBroadcasters( 
sc::ColumnBlockPosition rBlockPos, SCROW nRo
 maBroadcasters.set_empty(rBlockPos.miBroadcasterPos, nRow1, nRow2);
 }
 
+void ScColumn::PrepareBroadcastersForDestruction()
+{
+sc::BroadcasterStoreType::iterator itPos = maBroadcasters.begin(), 
itPosEnd = maBroadcasters.end();
+for (; itPos != itPosEnd; ++itPos)
+{
+if (itPos-type == sc::element_type_broadcaster)
+{
+sc::broadcaster_block::iterator it = 
sc::broadcaster_block::begin(*itPos-data);
+sc::broadcaster_block::iterator itEnd = 
sc::broadcaster_block::end(*itPos-data);
+for (; it != itEnd; ++it)
+(*it)-PrepareForDestruction();
+}
+}
+}
+
 bool ScColumn::HasBroadcaster() const
 {
 sc::BroadcasterStoreType::const_iterator it = maBroadcasters.begin(), 
itEnd = maBroadcasters.end();
diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index 4eed3b0..37417ac 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -341,6 +341,9 @@ ScTable::~ScTable()
 delete mpRangeName;
 delete pDBDataNoName;
 DestroySortCollator();
+
+for (SCCOL k=0; k=MAXCOL; k++)
+aCol[k].PrepareBroadcastersForDestruction();
 }
 
 void ScTable::GetName( OUString rName ) const
diff --git a/svl/source/notify/broadcast.cxx b/svl/source/notify/broadcast.cxx
index 24b5790..3575c7f 100644
--- a/svl/source/notify/broadcast.cxx
+++ b/svl/source/notify/broadcast.cxx
@@ -81,7 +81,7 @@ void SvtBroadcaster::Add( SvtListener* p )
 
 void SvtBroadcaster::Remove( SvtListener* p )
 {
-if (mbDisposing)
+if (mbAboutToDie || mbDisposing)
 return;
 
 Normalize();
@@ -94,10 +94,10 @@ void SvtBroadcaster::Remove( SvtListener* p )
 ListenersGone();
 }
 
-SvtBroadcaster::SvtBroadcaster() : mbDisposing(false), mbNormalized(false) {}
+SvtBroadcaster::SvtBroadcaster() : mbAboutToDie(false), mbDisposing(false), 
mbNormalized(false) {}
 
 SvtBroadcaster::SvtBroadcaster( const SvtBroadcaster rBC ) :
-maListeners(rBC.maListeners), mbDisposing(false), 
mbNormalized(rBC.mbNormalized)
+maListeners(rBC.maListeners), mbAboutToDie(false), mbDisposing(false), 
mbNormalized(rBC.mbNormalized)
 {