summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakeshi Abe <tabe@fixedpoint.jp>2018-08-28 17:12:00 +0900
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-09-28 13:33:46 +0200
commit7f7e890a10a710db57739cc1a6e0abfe7ae83530 (patch)
tree9937c6f0bb445cc5dafeb9c97195f0dd7b21e46b
parent2fbb97367ac93eb11429382f31fa6417eec76f8d (diff)
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@collabora.co.uk>
-rw-r--r--sd/source/core/sdpage.cxx10
1 files changed, 5 insertions, 5 deletions
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;
}