Kaydet (Commit) a65918c5 authored tarafından Noel Grandin's avatar Noel Grandin

tdf#125372 writer, file with lots of hints very slow to open, part4

Takes load time from 4m to 3m

Use equal_range to give us a start and an end, so we avoid the operator<
cost while scanning

Change-Id: Ie57d460237cddaacecdc6032136f614e02d13760
Reviewed-on: https://gerrit.libreoffice.org/73124
Tested-by: Jenkins
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 51fd9936
...@@ -161,6 +161,11 @@ namespace ...@@ -161,6 +161,11 @@ namespace
struct CompareIMarkStartsBefore struct CompareIMarkStartsBefore
{ {
bool operator()(SwPosition const& rPos,
std::shared_ptr<sw::mark::IMark> const& pMark)
{
return rPos < pMark->GetMarkStart();
}
bool operator()(std::shared_ptr<sw::mark::IMark> const& pMark, bool operator()(std::shared_ptr<sw::mark::IMark> const& pMark,
SwPosition const& rPos) SwPosition const& rPos)
{ {
...@@ -1039,15 +1044,13 @@ namespace sw { namespace mark ...@@ -1039,15 +1044,13 @@ namespace sw { namespace mark
" - Mark is not in my doc."); " - Mark is not in my doc.");
// finds the last Mark that is starting before pMark // finds the last Mark that is starting before pMark
// (pMarkLow < pMark) // (pMarkLow < pMark)
auto it = lower_bound( auto [it, endIt] = equal_range(
m_vAllMarks.begin(), m_vAllMarks.begin(),
m_vAllMarks.end(), m_vAllMarks.end(),
pMark->GetMarkStart(), pMark->GetMarkStart(),
CompareIMarkStartsBefore()); CompareIMarkStartsBefore());
for ( ; it != m_vAllMarks.end(); ++it) for ( ; it != endIt; ++it)
if (pMark->GetMarkStart() < (*it)->GetMarkStart()) if (it->get() == pMark)
break;
else if (it->get() == pMark)
{ {
deleteMark(it); deleteMark(it);
break; break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment