sw/source/core/doc/docbm.cxx       |   12 +++++++++---
 sw/source/core/inc/MarkManager.hxx |    2 ++
 2 files changed, 11 insertions(+), 3 deletions(-)

New commits:
commit a9670e0735b77ecc40aa8af4106af7d32ec548a0
Author: Cor Nouws <oo...@nouenoff.nl>
Date:   Wed Sep 23 00:40:06 2015 +0200

    tdf#86397  Bookmark: no consecutive name numbering applied when copied
    
    this partially changes behaviour introduced with commit 
bb00a0097900ae054401f7758a915047cfde4065
    but without the performace problems from the old code
    thanks to kendy for helping
    
    (cherry picked from commit 2fcf8923d2c520a5a16b1b3a45877adaadd7eab4)
    
    Change-Id: I5dab81b58262f67db1c70223c612636a8b8c90ee
    Reviewed-on: https://gerrit.libreoffice.org/18816
    Reviewed-by: Miklos Vajna <vmik...@collabora.co.uk>
    Tested-by: Miklos Vajna <vmik...@collabora.co.uk>

diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx
index be4805c..9b93a37 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;
     }
 
diff --git a/sw/source/core/inc/MarkManager.hxx 
b/sw/source/core/inc/MarkManager.hxx
index 50186fd..b797764 100644
--- a/sw/source/core/inc/MarkManager.hxx
+++ b/sw/source/core/inc/MarkManager.hxx
@@ -27,6 +27,7 @@
 
 namespace sw {
     namespace mark {
+    typedef std::unordered_map<OUString, sal_Int32, OUStringHash> 
MarkBasenameMapUniqueOffset_t;
 
     class MarkManager
         : private ::boost::noncopyable
@@ -109,6 +110,7 @@ namespace sw {
             container_t m_vFieldmarks;
 
             std::unordered_set<OUString, OUStringHash> m_aMarkNamesSet;
+            mutable MarkBasenameMapUniqueOffset_t 
m_aMarkBasenameMapUniqueOffset;
 
             // container for annotation marks
             container_t m_vAnnotationMarks;
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to