sw/source/core/doc/doc.cxx |   13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

New commits:
commit 51270f84bbeed46b3253ecfa1f8ddd408106b746
Author: Michael Meeks <michael.me...@suse.com>
Date:   Mon May 14 22:32:37 2012 +0100

    sw: avoid over-using over-complicated SfxUndoManager::IsUndoEnabled

diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx
index 4761473..1d4121c 100644
--- a/sw/source/core/doc/doc.cxx
+++ b/sw/source/core/doc/doc.cxx
@@ -909,10 +909,10 @@ bool SwDoc::AppendTxtNode( SwPosition& rPos )
 bool SwDoc::InsertString( const SwPaM &rRg, const String &rStr,
         const enum InsertFlags nInsertMode )
 {
-    if (GetIDocumentUndoRedo().DoesUndo())
-    {
+    // fetching DoesUndo is surprisingly expensive
+    bool bDoesUndo = GetIDocumentUndoRedo().DoesUndo();
+    if (bDoesUndo)
         GetIDocumentUndoRedo().ClearRedo(); // AppendUndo not always called!
-    }
 
     const SwPosition& rPos = *rRg.GetPoint();
 
@@ -927,18 +927,15 @@ bool SwDoc::InsertString( const SwPaM &rRg, const String 
&rStr,
 
     SwTxtNode *const pNode = rPos.nNode.GetNode().GetTxtNode();
     if(!pNode)
-    {
         return false;
-    }
 
     SwDataChanged aTmp( rRg, 0 );
 
-    if (!GetIDocumentUndoRedo().DoesUndo() ||
-        !GetIDocumentUndoRedo().DoesGroupUndo())
+    if (!bDoesUndo || !GetIDocumentUndoRedo().DoesGroupUndo())
     {
         pNode->InsertText( rStr, rPos.nContent, nInsertMode );
 
-        if (GetIDocumentUndoRedo().DoesUndo())
+        if (bDoesUndo)
         {
             SwUndoInsert * const pUndo( new SwUndoInsert(
                 rPos.nNode, rPos.nContent.GetIndex(), rStr.Len(), 
nInsertMode));
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to