[Libreoffice-commits] core.git: Branch 'libreoffice-7-0' - svl/source
LuboÅ¡ LuÅák (via logerrit)
logerrit at kemper.freedesktop.org
Fri Jun 26 05:58:02 UTC 2020
svl/source/notify/broadcast.cxx | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
New commits:
commit 0d7a20d965a2c0ad409f684bf4b7a359c39a61a7
Author: Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Thu Jun 25 10:02:47 2020 +0200
Commit: Adolfo Jayme Barrientos <fitojb at ubuntu.com>
CommitDate: Fri Jun 26 07:57:22 2020 +0200
optimize SvtBroadcaster::Normalize() a bit more (tdf#132454)
A common case is just one unsorted item at the end, in that case
it's even more efficient to simply insert it in the right place.
This further improves the tdf#132454 undo operation 36s->27s.
Change-Id: I29db80fb8292e827b655000cddc462cf87cb485d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97088
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
Reviewed-by: Luboš Luňák <l.lunak at collabora.com>
Tested-by: Jenkins
(cherry picked from commit 845646ebda70078a7b5264d985583aa6c221db10)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97058
Reviewed-by: Adolfo Jayme Barrientos <fitojb at ubuntu.com>
diff --git a/svl/source/notify/broadcast.cxx b/svl/source/notify/broadcast.cxx
index cc1ffcb10917..de7ec6b4374e 100644
--- a/svl/source/notify/broadcast.cxx
+++ b/svl/source/notify/broadcast.cxx
@@ -29,13 +29,20 @@ void SvtBroadcaster::Normalize() const
if (!mbNormalized)
{
// Add() only appends new values, so often the container will be sorted expect for one
- // or few last items. For larger containers it is much more efficient to just sort
- // the unsorted part and then merge.
+ // or few last items. For larger containers it is much more efficient to just handle
+ // the unsorted part.
if(maListeners.size() > 100)
{
auto sortedEnd = std::is_sorted_until(maListeners.begin(),maListeners.end());
- if( o3tl::make_unsigned( sortedEnd - maListeners.begin()) > maListeners.size() * 3 / 4 )
- {
+ if( maListeners.end() - sortedEnd == 1 )
+ { // Just one item, insert it in the right place.
+ SvtListener* item = maListeners.back();
+ maListeners.pop_back();
+ maListeners.insert( std::upper_bound( maListeners.begin(), maListeners.end(), item ), item );
+ mbNormalized = true;
+ }
+ else if( o3tl::make_unsigned( sortedEnd - maListeners.begin()) > maListeners.size() * 3 / 4 )
+ { // Sort the unsorted part and then merge.
std::sort( sortedEnd, maListeners.end());
std::inplace_merge( maListeners.begin(), sortedEnd, maListeners.end());
mbNormalized = true;
More information about the Libreoffice-commits
mailing list