[Libreoffice-commits] core.git: sd/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Fri Sep 28 11:34:12 UTC 2018
sd/source/core/sdpage.cxx | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
New commits:
commit 7f7e890a10a710db57739cc1a6e0abfe7ae83530
Author: Takeshi Abe <tabe at fixedpoint.jp>
AuthorDate: Tue Aug 28 17:12:00 2018 +0900
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri Sep 28 13:33:46 2018 +0200
sd: micro-optimize SdPage::GetPresObj() by sorting less
No need to sort all matched elements.
Change-Id: I4133b28a9c84ab322e55f9987859690e426f600c
Reviewed-on: https://gerrit.libreoffice.org/59691
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/sd/source/core/sdpage.cxx b/sd/source/core/sdpage.cxx
index 6a86108e47b2..dc6c85dc20d8 100644
--- a/sd/source/core/sdpage.cxx
+++ b/sd/source/core/sdpage.cxx
@@ -232,16 +232,16 @@ SdrObject* SdPage::GetPresObj(PresObjKind eObjKind, int nIndex, bool bFuzzySearc
}
}
- if( aMatches.size() > 1 )
- {
- std::sort( aMatches.begin(), aMatches.end(), OrdNumSorter() );
- }
-
if( nIndex > 0 )
nIndex--;
if( (nIndex >= 0) && ( aMatches.size() > static_cast<unsigned int>(nIndex)) )
+ {
+ if( aMatches.size() > 1 )
+ std::nth_element( aMatches.begin(), aMatches.begin() + nIndex, aMatches.end(),
+ OrdNumSorter() );
return aMatches[nIndex];
+ }
return nullptr;
}
More information about the Libreoffice-commits
mailing list