summaryrefslogtreecommitdiff
path: root/sw/source/core/doc/docbm.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sw/source/core/doc/docbm.cxx')
-rw-r--r--sw/source/core/doc/docbm.cxx12
1 files changed, 9 insertions, 3 deletions
diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx
index be4805ca63ee..9b93a37ee1a4 100644
--- a/sw/source/core/doc/docbm.cxx
+++ b/sw/source/core/doc/docbm.cxx
@@ -1108,9 +1108,13 @@ namespace sw { namespace mark
OUStringBuffer sBuf;
OUString sTmp;
- // Try the name "<rName>XXX", where XXX is a number. Start the number at the existing count rather than 1
- // in order to increase the chance that already the first one will not exist.
- sal_Int32 nCnt = m_vAllMarks.size() + 1;
+ // try the name "<rName>XXX" (where XXX is a number starting from 1) unless there is
+ // a unused name. Due to performance-reasons (especially in mailmerge-Szenarios) there
+ // is a map m_aMarkBasenameMapUniqueOffset which holds the next possible offset (XXX) for
+ // rName (so there is no need to test for nCnt-values smaller than the offset).
+ sal_Int32 nCnt = 1;
+ MarkBasenameMapUniqueOffset_t::const_iterator aIter = m_aMarkBasenameMapUniqueOffset.find(rName);
+ if(aIter != m_aMarkBasenameMapUniqueOffset.end()) nCnt = aIter->second;
while(nCnt < SAL_MAX_INT32)
{
sTmp = sBuf.append(rName).append(nCnt).makeStringAndClear();
@@ -1120,6 +1124,8 @@ namespace sw { namespace mark
break;
}
}
+ m_aMarkBasenameMapUniqueOffset[rName] = nCnt;
+
return sTmp;
}